vlambda 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vlambda-0.2.3 → vlambda-0.3.0}/PKG-INFO +74 -14
- {vlambda-0.2.3 → vlambda-0.3.0}/README.md +73 -13
- {vlambda-0.2.3 → vlambda-0.3.0}/pyproject.toml +1 -1
- vlambda-0.3.0/python/vlambda/__init__.py +10 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/__main__.py +122 -70
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/assets.py +1 -1
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/auth.py +24 -6
- vlambda-0.3.0/python/vlambda/cli.py +181 -0
- vlambda-0.3.0/python/vlambda/dbpool.py +59 -0
- vlambda-0.3.0/python/vlambda/env.py +185 -0
- vlambda-0.3.0/python/vlambda/forkd.py +150 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/metrics.py +51 -9
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/pool.py +221 -37
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/project.py +36 -27
- vlambda-0.3.0/python/vlambda/request.py +71 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/reset.py +3 -6
- vlambda-0.3.0/python/vlambda/response.py +152 -0
- vlambda-0.3.0/python/vlambda/runner.py +170 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/sandbox.py +2 -14
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/shared_cache.py +5 -1
- vlambda-0.3.0/python/vlambda/tasks.py +206 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/transfer.py +20 -18
- {vlambda-0.2.3 → vlambda-0.3.0}/src/vlambda_native.v +404 -108
- {vlambda-0.2.3 → vlambda-0.3.0}/tests/test_unit.py +245 -2
- {vlambda-0.2.3 → vlambda-0.3.0}/tests/test_vlambda.py +342 -5
- {vlambda-0.2.3 → vlambda-0.3.0}/vcraft.toml +1 -1
- vlambda-0.2.3/python/vlambda/__init__.py +0 -3
- vlambda-0.2.3/python/vlambda/dbpool.py +0 -49
- vlambda-0.2.3/python/vlambda/request.py +0 -23
- vlambda-0.2.3/python/vlambda/runner.py +0 -122
- vlambda-0.2.3/python/vlambda/tasks.py +0 -102
- {vlambda-0.2.3 → vlambda-0.3.0}/LICENSE +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/cache.py +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/packages.py +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/py.typed +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/python/vlambda/sandbox_os.py +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/tests/conftest.py +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/v.mod +0 -0
- {vlambda-0.2.3 → vlambda-0.3.0}/vcraft_build.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vlambda
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: An ASGI-like server for Python lambdas, written in V.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.14
|
|
@@ -17,7 +17,7 @@ An ASGI-like server for Python lambdas, written in V. Uses [vcraft](https://gith
|
|
|
17
17
|
|
|
18
18
|
## What is vlambda?
|
|
19
19
|
|
|
20
|
-
vlambda lets you write Python functions ("lambdas") and serve them as HTTP endpoints. It's like AWS Lambda, but self-hosted, with no cold
|
|
20
|
+
vlambda lets you write Python functions ("lambdas") and serve them as HTTP endpoints. It's like AWS Lambda, but self-hosted, with no cold start in persistent mode and a fresh sandbox per invocation in Docker (~10-20 ms p50).
|
|
21
21
|
|
|
22
22
|
```python
|
|
23
23
|
def handler(request):
|
|
@@ -29,7 +29,7 @@ POST that code to `/vlambda` and it becomes `GET /f/<slug>` instantly.
|
|
|
29
29
|
## Features
|
|
30
30
|
|
|
31
31
|
- **No cold starts in persistent mode** — Docker uses a fresh Landlock process per invocation, which adds a small startup cost
|
|
32
|
-
- **Fast** — ~3,000 req/s
|
|
32
|
+
- **Fast** — ~3,000 req/s in-process; the Docker fork sandbox adds a few milliseconds per invocation
|
|
33
33
|
- **Auth** — JWT-based authentication with per-user ownership
|
|
34
34
|
- **Web UI** — Dashboard for managing lambdas, code editor, metrics
|
|
35
35
|
- **Async invocation** — Fire-and-forget with task tracking
|
|
@@ -103,9 +103,9 @@ token with `DELETE /tokens/<id>`. Tokens do not expire.
|
|
|
103
103
|
|
|
104
104
|
The repository includes a production image (`Dockerfile`, installs from PyPI) and
|
|
105
105
|
a development image (`Dockerfile.dev`, builds the local wheel). Both use a
|
|
106
|
-
free-threaded Python 3.14 venv,
|
|
107
|
-
|
|
108
|
-
TLS and the public domain.
|
|
106
|
+
free-threaded Python 3.14 venv, a pre-warmed fork supervisor and a fresh
|
|
107
|
+
Landlock + seccomp child per invocation, and expose plain HTTP on port `8080`;
|
|
108
|
+
Dokploy (or another proxy) handles TLS and the public domain.
|
|
109
109
|
|
|
110
110
|
The sandbox needs no extra Docker flags, capabilities or host sysctl changes.
|
|
111
111
|
It requires a Linux kernel with Landlock (5.13+; Ubuntu 22.04+, Debian 12+).
|
|
@@ -137,6 +137,13 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
137
137
|
| `--cert` | `VLAMBDA_CERT` | | TLS certificate path |
|
|
138
138
|
| `--key` | `VLAMBDA_KEY` | | TLS key path |
|
|
139
139
|
| | `VLAMBDA_REGISTRATION` | 1 | Allow public registration (`0` disables it) |
|
|
140
|
+
| | `VLAMBDA_RESP_CACHE_TTL` | 0 | GET response cache TTL in seconds (0 disables it) |
|
|
141
|
+
| | `VLAMBDA_CACHE_BACKEND` | memory | `memory`, `file` or `redis` for the optional response cache |
|
|
142
|
+
|
|
143
|
+
The GET response cache is disabled by default because a handler can depend on
|
|
144
|
+
headers, cookies, `request.env`, time or other request state. Enable it only for
|
|
145
|
+
stateless, idempotent GET lambdas; handlers that read request context, log,
|
|
146
|
+
`random` or `time.time` are skipped automatically.
|
|
140
147
|
|
|
141
148
|
## API
|
|
142
149
|
|
|
@@ -153,6 +160,8 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
153
160
|
- `GET /vlambda/<slug>` — Get lambda code
|
|
154
161
|
- `PUT /vlambda/<slug>?method=POST&name=new-name` — Update lambda
|
|
155
162
|
- `DELETE /vlambda/<slug>` — Delete lambda
|
|
163
|
+
- `GET /vlambda/<slug>/env` — List environment variables (secrets masked)
|
|
164
|
+
- `PUT /vlambda/<slug>/env` — Replace vars/secrets: `{"vars": {...}, "secrets": {...}}`
|
|
156
165
|
|
|
157
166
|
### API tokens (requires auth)
|
|
158
167
|
- `POST /tokens` — Create a token: `{"name":"ci","scopes":["read","write"]}`
|
|
@@ -212,7 +221,7 @@ Project exports include text files. Binary files are listed in
|
|
|
212
221
|
- `GET /logs/history?days=N&slug=` — Persisted lambda logs
|
|
213
222
|
- `DELETE /logs/history?days=N&slug=` — Delete logs older than N days (`days=0` deletes all)
|
|
214
223
|
- `GET /pool/stats`, `GET /dlq`
|
|
215
|
-
- `POST /shutdown` — Graceful shutdown
|
|
224
|
+
- `POST /shutdown` — Graceful shutdown (requires `X-Admin-Token`)
|
|
216
225
|
|
|
217
226
|
## Logging
|
|
218
227
|
|
|
@@ -229,20 +238,35 @@ Logs are stored in the metrics database and can be queried with
|
|
|
229
238
|
`GET /logs/history?days=1&slug=<slug>`. The UI Logs view shows them alongside
|
|
230
239
|
invocations. The "Save logs" template in the editor is a ready-to-run example.
|
|
231
240
|
|
|
241
|
+
Metrics and logs are scoped to the authenticated user. The admin token
|
|
242
|
+
(`X-Admin-Token`) can query all users through the API/CLI.
|
|
243
|
+
|
|
232
244
|
Metrics and logs are pruned after `VLAMBDA_METRICS_RETENTION` days (default 7).
|
|
233
245
|
From the UI you can also prune data older than the selected period, or delete
|
|
234
246
|
all matching rows, with the current lambda filter applied.
|
|
235
247
|
|
|
236
248
|
## Lambda Format
|
|
237
249
|
|
|
238
|
-
Every lambda must define a `handler` function
|
|
250
|
+
Every lambda must define a `handler` function. The canonical contract returns a
|
|
251
|
+
`Response`; returning a `dict`, `str` or `bytes` is still accepted as shorthand:
|
|
239
252
|
|
|
240
253
|
```python
|
|
254
|
+
from vlambda import Response
|
|
255
|
+
|
|
241
256
|
def handler(request):
|
|
242
|
-
return
|
|
257
|
+
return Response.json(
|
|
258
|
+
{"msg": "hello", "path": request.path},
|
|
259
|
+
status=201,
|
|
260
|
+
headers={"X-Example": "yes"},
|
|
261
|
+
)
|
|
243
262
|
```
|
|
244
263
|
|
|
245
|
-
The `request` object has: `method`, `path`, `query_string`, `
|
|
264
|
+
The `request` object has: `method`, `path`, `query_string`, `query`, `headers`,
|
|
265
|
+
`cookies`, `body`, `remote_ip`, `host`, `scheme`, `request_id`, `slug`, `env`,
|
|
266
|
+
and helpers `header()`, `json()`, `form()` and `log()`.
|
|
267
|
+
|
|
268
|
+
`Response` supports `json()`, `text()`, `html()`, `redirect()`, `no_content()`,
|
|
269
|
+
status codes, headers, cookies and binary bodies.
|
|
246
270
|
|
|
247
271
|
Safe builtins: `abs`, `all`, `any`, `bool`, `dict`, `enumerate`, `filter`, `float`, `int`, `len`, `list`, `map`, `max`, `min`, `range`, `reversed`, `round`, `set`, `sorted`, `str`, `sum`, `tuple`, `zip`, `print`, etc.
|
|
248
272
|
|
|
@@ -252,13 +276,19 @@ Safe modules: `json`, `math`, `re`, `datetime`, `collections`, `itertools`, `fun
|
|
|
252
276
|
|
|
253
277
|
### Security
|
|
254
278
|
|
|
255
|
-
|
|
279
|
+
With the Docker default (`VLAMBDA_SANDBOX=fork`), user code runs in a fresh
|
|
280
|
+
runner process confined with Landlock and seccomp.
|
|
256
281
|
Landlock limits the filesystem to `/opt`, `/usr`, `/lib`, `/etc`, the current
|
|
257
282
|
project/vendor and a private temporary directory; `/data`, `/proc`, `/sys` and
|
|
258
283
|
the rest of the server cannot be read or listed. seccomp blocks network, cross-process
|
|
259
284
|
signals, `ptrace`, `mount`, namespace changes and similar syscalls. Resource
|
|
260
285
|
limits are applied too, and each invocation gets a fresh process.
|
|
261
286
|
|
|
287
|
+
The plain `python -m vlambda` command without `VLAMBDA_SANDBOX` uses the
|
|
288
|
+
in-process pool and is a development mode: lambdas run inside the server process
|
|
289
|
+
with only Python-level restrictions. Use `VLAMBDA_SANDBOX=fork` (Docker default),
|
|
290
|
+
`landlock`, `process` or `nsjail` for any untrusted code.
|
|
291
|
+
|
|
262
292
|
The Docker image keeps public registration open by default for toy deployments.
|
|
263
293
|
Set `VLAMBDA_REGISTRATION=0` to close it and create users with
|
|
264
294
|
`POST /admin/users` instead. A daily data reset removes state, but it does not
|
|
@@ -266,6 +296,35 @@ undo a kernel-level escape. Keep this deployment disposable and do not store
|
|
|
266
296
|
valuable secrets in it; for stronger isolation use gVisor, Firecracker or one
|
|
267
297
|
container per tenant.
|
|
268
298
|
|
|
299
|
+
## Environment and secrets
|
|
300
|
+
|
|
301
|
+
Set per-lambda variables with `PUT /vlambda/<slug>/env`:
|
|
302
|
+
|
|
303
|
+
```json
|
|
304
|
+
{
|
|
305
|
+
"vars": {"PLAIN": "hello"},
|
|
306
|
+
"secrets": {"TOKEN": "s3cret"}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Secrets are encrypted at rest, masked by the API and decrypted only for that
|
|
311
|
+
lambda's runner. Code lambdas read them from `request.env`; projects also see
|
|
312
|
+
them in `os.environ`. Use `VLAMBDA_ENCRYPTION_KEY` if you want to rotate
|
|
313
|
+
`VLAMBDA_SECRET` without losing existing secrets.
|
|
314
|
+
|
|
315
|
+
## CLI
|
|
316
|
+
|
|
317
|
+
The CLI talks to a running server and uses `VLAMBDA_URL`/`VLAMBDA_TOKEN` or
|
|
318
|
+
`--url`/`--token`:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
python -m vlambda deploy main.py --name my-lambda --method GET
|
|
322
|
+
python -m vlambda invoke <slug>
|
|
323
|
+
python -m vlambda logs --slug <slug> --days 1
|
|
324
|
+
python -m vlambda env <slug> --set PLAIN=hello --secret TOKEN=s3cret
|
|
325
|
+
python -m vlambda task <task-id>
|
|
326
|
+
```
|
|
327
|
+
|
|
269
328
|
## Web UI
|
|
270
329
|
|
|
271
330
|
Open http://localhost:8080/ in your browser for the dashboard:
|
|
@@ -301,9 +360,10 @@ For a disposable demo, run it from cron every day:
|
|
|
301
360
|
| Metric | Value |
|
|
302
361
|
|--------|-------|
|
|
303
362
|
| Cold start | 0ms in persistent mode; fresh sandbox process in Docker |
|
|
304
|
-
| Warm invocation | ~0.3ms |
|
|
305
|
-
|
|
|
306
|
-
| Throughput (
|
|
363
|
+
| Warm invocation (in-process) | ~0.3ms |
|
|
364
|
+
| Warm invocation (Docker fork sandbox) | ~10-20ms p50 |
|
|
365
|
+
| Throughput (concurrent, free-threaded) | ~3,000 req/s in-process |
|
|
366
|
+
| Response cache | Opt-in via `VLAMBDA_RESP_CACHE_TTL`; ~100x faster for stateless GETs |
|
|
307
367
|
|
|
308
368
|
## Architecture
|
|
309
369
|
|
|
@@ -6,7 +6,7 @@ An ASGI-like server for Python lambdas, written in V. Uses [vcraft](https://gith
|
|
|
6
6
|
|
|
7
7
|
## What is vlambda?
|
|
8
8
|
|
|
9
|
-
vlambda lets you write Python functions ("lambdas") and serve them as HTTP endpoints. It's like AWS Lambda, but self-hosted, with no cold
|
|
9
|
+
vlambda lets you write Python functions ("lambdas") and serve them as HTTP endpoints. It's like AWS Lambda, but self-hosted, with no cold start in persistent mode and a fresh sandbox per invocation in Docker (~10-20 ms p50).
|
|
10
10
|
|
|
11
11
|
```python
|
|
12
12
|
def handler(request):
|
|
@@ -18,7 +18,7 @@ POST that code to `/vlambda` and it becomes `GET /f/<slug>` instantly.
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
20
|
- **No cold starts in persistent mode** — Docker uses a fresh Landlock process per invocation, which adds a small startup cost
|
|
21
|
-
- **Fast** — ~3,000 req/s
|
|
21
|
+
- **Fast** — ~3,000 req/s in-process; the Docker fork sandbox adds a few milliseconds per invocation
|
|
22
22
|
- **Auth** — JWT-based authentication with per-user ownership
|
|
23
23
|
- **Web UI** — Dashboard for managing lambdas, code editor, metrics
|
|
24
24
|
- **Async invocation** — Fire-and-forget with task tracking
|
|
@@ -92,9 +92,9 @@ token with `DELETE /tokens/<id>`. Tokens do not expire.
|
|
|
92
92
|
|
|
93
93
|
The repository includes a production image (`Dockerfile`, installs from PyPI) and
|
|
94
94
|
a development image (`Dockerfile.dev`, builds the local wheel). Both use a
|
|
95
|
-
free-threaded Python 3.14 venv,
|
|
96
|
-
|
|
97
|
-
TLS and the public domain.
|
|
95
|
+
free-threaded Python 3.14 venv, a pre-warmed fork supervisor and a fresh
|
|
96
|
+
Landlock + seccomp child per invocation, and expose plain HTTP on port `8080`;
|
|
97
|
+
Dokploy (or another proxy) handles TLS and the public domain.
|
|
98
98
|
|
|
99
99
|
The sandbox needs no extra Docker flags, capabilities or host sysctl changes.
|
|
100
100
|
It requires a Linux kernel with Landlock (5.13+; Ubuntu 22.04+, Debian 12+).
|
|
@@ -126,6 +126,13 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
126
126
|
| `--cert` | `VLAMBDA_CERT` | | TLS certificate path |
|
|
127
127
|
| `--key` | `VLAMBDA_KEY` | | TLS key path |
|
|
128
128
|
| | `VLAMBDA_REGISTRATION` | 1 | Allow public registration (`0` disables it) |
|
|
129
|
+
| | `VLAMBDA_RESP_CACHE_TTL` | 0 | GET response cache TTL in seconds (0 disables it) |
|
|
130
|
+
| | `VLAMBDA_CACHE_BACKEND` | memory | `memory`, `file` or `redis` for the optional response cache |
|
|
131
|
+
|
|
132
|
+
The GET response cache is disabled by default because a handler can depend on
|
|
133
|
+
headers, cookies, `request.env`, time or other request state. Enable it only for
|
|
134
|
+
stateless, idempotent GET lambdas; handlers that read request context, log,
|
|
135
|
+
`random` or `time.time` are skipped automatically.
|
|
129
136
|
|
|
130
137
|
## API
|
|
131
138
|
|
|
@@ -142,6 +149,8 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
142
149
|
- `GET /vlambda/<slug>` — Get lambda code
|
|
143
150
|
- `PUT /vlambda/<slug>?method=POST&name=new-name` — Update lambda
|
|
144
151
|
- `DELETE /vlambda/<slug>` — Delete lambda
|
|
152
|
+
- `GET /vlambda/<slug>/env` — List environment variables (secrets masked)
|
|
153
|
+
- `PUT /vlambda/<slug>/env` — Replace vars/secrets: `{"vars": {...}, "secrets": {...}}`
|
|
145
154
|
|
|
146
155
|
### API tokens (requires auth)
|
|
147
156
|
- `POST /tokens` — Create a token: `{"name":"ci","scopes":["read","write"]}`
|
|
@@ -201,7 +210,7 @@ Project exports include text files. Binary files are listed in
|
|
|
201
210
|
- `GET /logs/history?days=N&slug=` — Persisted lambda logs
|
|
202
211
|
- `DELETE /logs/history?days=N&slug=` — Delete logs older than N days (`days=0` deletes all)
|
|
203
212
|
- `GET /pool/stats`, `GET /dlq`
|
|
204
|
-
- `POST /shutdown` — Graceful shutdown
|
|
213
|
+
- `POST /shutdown` — Graceful shutdown (requires `X-Admin-Token`)
|
|
205
214
|
|
|
206
215
|
## Logging
|
|
207
216
|
|
|
@@ -218,20 +227,35 @@ Logs are stored in the metrics database and can be queried with
|
|
|
218
227
|
`GET /logs/history?days=1&slug=<slug>`. The UI Logs view shows them alongside
|
|
219
228
|
invocations. The "Save logs" template in the editor is a ready-to-run example.
|
|
220
229
|
|
|
230
|
+
Metrics and logs are scoped to the authenticated user. The admin token
|
|
231
|
+
(`X-Admin-Token`) can query all users through the API/CLI.
|
|
232
|
+
|
|
221
233
|
Metrics and logs are pruned after `VLAMBDA_METRICS_RETENTION` days (default 7).
|
|
222
234
|
From the UI you can also prune data older than the selected period, or delete
|
|
223
235
|
all matching rows, with the current lambda filter applied.
|
|
224
236
|
|
|
225
237
|
## Lambda Format
|
|
226
238
|
|
|
227
|
-
Every lambda must define a `handler` function
|
|
239
|
+
Every lambda must define a `handler` function. The canonical contract returns a
|
|
240
|
+
`Response`; returning a `dict`, `str` or `bytes` is still accepted as shorthand:
|
|
228
241
|
|
|
229
242
|
```python
|
|
243
|
+
from vlambda import Response
|
|
244
|
+
|
|
230
245
|
def handler(request):
|
|
231
|
-
return
|
|
246
|
+
return Response.json(
|
|
247
|
+
{"msg": "hello", "path": request.path},
|
|
248
|
+
status=201,
|
|
249
|
+
headers={"X-Example": "yes"},
|
|
250
|
+
)
|
|
232
251
|
```
|
|
233
252
|
|
|
234
|
-
The `request` object has: `method`, `path`, `query_string`, `
|
|
253
|
+
The `request` object has: `method`, `path`, `query_string`, `query`, `headers`,
|
|
254
|
+
`cookies`, `body`, `remote_ip`, `host`, `scheme`, `request_id`, `slug`, `env`,
|
|
255
|
+
and helpers `header()`, `json()`, `form()` and `log()`.
|
|
256
|
+
|
|
257
|
+
`Response` supports `json()`, `text()`, `html()`, `redirect()`, `no_content()`,
|
|
258
|
+
status codes, headers, cookies and binary bodies.
|
|
235
259
|
|
|
236
260
|
Safe builtins: `abs`, `all`, `any`, `bool`, `dict`, `enumerate`, `filter`, `float`, `int`, `len`, `list`, `map`, `max`, `min`, `range`, `reversed`, `round`, `set`, `sorted`, `str`, `sum`, `tuple`, `zip`, `print`, etc.
|
|
237
261
|
|
|
@@ -241,13 +265,19 @@ Safe modules: `json`, `math`, `re`, `datetime`, `collections`, `itertools`, `fun
|
|
|
241
265
|
|
|
242
266
|
### Security
|
|
243
267
|
|
|
244
|
-
|
|
268
|
+
With the Docker default (`VLAMBDA_SANDBOX=fork`), user code runs in a fresh
|
|
269
|
+
runner process confined with Landlock and seccomp.
|
|
245
270
|
Landlock limits the filesystem to `/opt`, `/usr`, `/lib`, `/etc`, the current
|
|
246
271
|
project/vendor and a private temporary directory; `/data`, `/proc`, `/sys` and
|
|
247
272
|
the rest of the server cannot be read or listed. seccomp blocks network, cross-process
|
|
248
273
|
signals, `ptrace`, `mount`, namespace changes and similar syscalls. Resource
|
|
249
274
|
limits are applied too, and each invocation gets a fresh process.
|
|
250
275
|
|
|
276
|
+
The plain `python -m vlambda` command without `VLAMBDA_SANDBOX` uses the
|
|
277
|
+
in-process pool and is a development mode: lambdas run inside the server process
|
|
278
|
+
with only Python-level restrictions. Use `VLAMBDA_SANDBOX=fork` (Docker default),
|
|
279
|
+
`landlock`, `process` or `nsjail` for any untrusted code.
|
|
280
|
+
|
|
251
281
|
The Docker image keeps public registration open by default for toy deployments.
|
|
252
282
|
Set `VLAMBDA_REGISTRATION=0` to close it and create users with
|
|
253
283
|
`POST /admin/users` instead. A daily data reset removes state, but it does not
|
|
@@ -255,6 +285,35 @@ undo a kernel-level escape. Keep this deployment disposable and do not store
|
|
|
255
285
|
valuable secrets in it; for stronger isolation use gVisor, Firecracker or one
|
|
256
286
|
container per tenant.
|
|
257
287
|
|
|
288
|
+
## Environment and secrets
|
|
289
|
+
|
|
290
|
+
Set per-lambda variables with `PUT /vlambda/<slug>/env`:
|
|
291
|
+
|
|
292
|
+
```json
|
|
293
|
+
{
|
|
294
|
+
"vars": {"PLAIN": "hello"},
|
|
295
|
+
"secrets": {"TOKEN": "s3cret"}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Secrets are encrypted at rest, masked by the API and decrypted only for that
|
|
300
|
+
lambda's runner. Code lambdas read them from `request.env`; projects also see
|
|
301
|
+
them in `os.environ`. Use `VLAMBDA_ENCRYPTION_KEY` if you want to rotate
|
|
302
|
+
`VLAMBDA_SECRET` without losing existing secrets.
|
|
303
|
+
|
|
304
|
+
## CLI
|
|
305
|
+
|
|
306
|
+
The CLI talks to a running server and uses `VLAMBDA_URL`/`VLAMBDA_TOKEN` or
|
|
307
|
+
`--url`/`--token`:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
python -m vlambda deploy main.py --name my-lambda --method GET
|
|
311
|
+
python -m vlambda invoke <slug>
|
|
312
|
+
python -m vlambda logs --slug <slug> --days 1
|
|
313
|
+
python -m vlambda env <slug> --set PLAIN=hello --secret TOKEN=s3cret
|
|
314
|
+
python -m vlambda task <task-id>
|
|
315
|
+
```
|
|
316
|
+
|
|
258
317
|
## Web UI
|
|
259
318
|
|
|
260
319
|
Open http://localhost:8080/ in your browser for the dashboard:
|
|
@@ -290,9 +349,10 @@ For a disposable demo, run it from cron every day:
|
|
|
290
349
|
| Metric | Value |
|
|
291
350
|
|--------|-------|
|
|
292
351
|
| Cold start | 0ms in persistent mode; fresh sandbox process in Docker |
|
|
293
|
-
| Warm invocation | ~0.3ms |
|
|
294
|
-
|
|
|
295
|
-
| Throughput (
|
|
352
|
+
| Warm invocation (in-process) | ~0.3ms |
|
|
353
|
+
| Warm invocation (Docker fork sandbox) | ~10-20ms p50 |
|
|
354
|
+
| Throughput (concurrent, free-threaded) | ~3,000 req/s in-process |
|
|
355
|
+
| Response cache | Opt-in via `VLAMBDA_RESP_CACHE_TTL`; ~100x faster for stateless GETs |
|
|
296
356
|
|
|
297
357
|
## Architecture
|
|
298
358
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""vlambda: an ASGI-like server for Python lambdas, written in V."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from vlambda.response import Response # noqa: F401
|
|
6
|
+
|
|
7
|
+
# Sandboxed runners only need the pure-Python modules; importing the native
|
|
8
|
+
# extension there adds startup latency without being used.
|
|
9
|
+
if os.environ.get("VLRUN_NO_NATIVE") != "1":
|
|
10
|
+
from vlambda_native import * # noqa: F401,F403
|