vlambda 0.2.4__tar.gz → 0.4.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.4 → vlambda-0.4.0}/PKG-INFO +269 -16
- {vlambda-0.2.4 → vlambda-0.4.0}/README.md +268 -15
- {vlambda-0.2.4 → vlambda-0.4.0}/pyproject.toml +1 -1
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/__init__.py +7 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/__main__.py +280 -81
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/assets.py +5 -1
- vlambda-0.4.0/python/vlambda/async_support.py +46 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/auth.py +24 -6
- vlambda-0.4.0/python/vlambda/broker.py +429 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/cache.py +28 -5
- vlambda-0.4.0/python/vlambda/capabilities.py +204 -0
- vlambda-0.4.0/python/vlambda/cli.py +303 -0
- vlambda-0.4.0/python/vlambda/cron.py +144 -0
- vlambda-0.4.0/python/vlambda/dbpool.py +63 -0
- vlambda-0.4.0/python/vlambda/egress_store.py +112 -0
- vlambda-0.4.0/python/vlambda/env.py +185 -0
- vlambda-0.4.0/python/vlambda/forkd.py +161 -0
- vlambda-0.4.0/python/vlambda/kv_store.py +313 -0
- vlambda-0.4.0/python/vlambda/lifecycle.py +70 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/metrics.py +56 -9
- vlambda-0.4.0/python/vlambda/openapi.py +213 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/pool.py +251 -47
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/project.py +39 -28
- vlambda-0.4.0/python/vlambda/request.py +77 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/reset.py +9 -6
- vlambda-0.4.0/python/vlambda/response.py +152 -0
- vlambda-0.4.0/python/vlambda/runner.py +185 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/sandbox.py +3 -2
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/sandbox_os.py +23 -4
- vlambda-0.4.0/python/vlambda/schedules.py +577 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/shared_cache.py +5 -1
- vlambda-0.4.0/python/vlambda/sqlite_compat.py +38 -0
- vlambda-0.4.0/python/vlambda/tasks.py +401 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/transfer.py +20 -18
- {vlambda-0.2.4 → vlambda-0.4.0}/src/vlambda_native.v +767 -144
- vlambda-0.4.0/tests/test_unit.py +1065 -0
- vlambda-0.4.0/tests/test_vlambda.py +1531 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/vcraft.toml +1 -1
- vlambda-0.2.4/python/vlambda/dbpool.py +0 -49
- vlambda-0.2.4/python/vlambda/request.py +0 -39
- vlambda-0.2.4/python/vlambda/runner.py +0 -137
- vlambda-0.2.4/python/vlambda/tasks.py +0 -102
- vlambda-0.2.4/tests/test_unit.py +0 -399
- vlambda-0.2.4/tests/test_vlambda.py +0 -792
- {vlambda-0.2.4 → vlambda-0.4.0}/LICENSE +0 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/packages.py +0 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/python/vlambda/py.typed +0 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/tests/conftest.py +0 -0
- {vlambda-0.2.4 → vlambda-0.4.0}/v.mod +0 -0
- {vlambda-0.2.4 → vlambda-0.4.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.4.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,10 +29,14 @@ 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
|
|
36
|
+
- **KV store** — per-lambda typed key/value state with TTL and atomic increments
|
|
37
|
+
- **Controlled egress** — allow-listed HTTPS calls from the sandbox via `request.fetch`
|
|
38
|
+
- **Schedules** — persistent five-field cron jobs with timezones, run history and a single leader
|
|
39
|
+
- **OpenAPI** — owner-scoped spec, metadata editor, `/docs` viewer and CLI export
|
|
36
40
|
- **Sandbox** — Landlock + seccomp in Docker, plus restricted Python builtins and blocked modules
|
|
37
41
|
- **Metrics** — Prometheus-compatible + Chart.js dashboard
|
|
38
42
|
- **Per-lambda method** — GET, POST, PUT, PATCH, DELETE
|
|
@@ -48,6 +52,13 @@ POST that code to `/vlambda` and it becomes `GET /f/<slug>` instantly.
|
|
|
48
52
|
- **POC templates** — HTML + `fetch`, webhook, JSON API, static site
|
|
49
53
|
- **Free-threaded builds** — `cp314t`/`cp315t` wheels
|
|
50
54
|
|
|
55
|
+
## Roadmap
|
|
56
|
+
|
|
57
|
+
0.4.0 is in planning: per-lambda KV, allow-listed egress, cron schedules,
|
|
58
|
+
OpenAPI, single-host HA and an optional gVisor runtime. See
|
|
59
|
+
[docs/ROADMAP-0.4.0.md](docs/ROADMAP-0.4.0.md) for architecture, API contracts,
|
|
60
|
+
phases and release criteria.
|
|
61
|
+
|
|
51
62
|
## Installation
|
|
52
63
|
|
|
53
64
|
```bash
|
|
@@ -103,9 +114,9 @@ token with `DELETE /tokens/<id>`. Tokens do not expire.
|
|
|
103
114
|
|
|
104
115
|
The repository includes a production image (`Dockerfile`, installs from PyPI) and
|
|
105
116
|
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.
|
|
117
|
+
free-threaded Python 3.14 venv, a pre-warmed fork supervisor and a fresh
|
|
118
|
+
Landlock + seccomp child per invocation, and expose plain HTTP on port `8080`;
|
|
119
|
+
Dokploy (or another proxy) handles TLS and the public domain.
|
|
109
120
|
|
|
110
121
|
The sandbox needs no extra Docker flags, capabilities or host sysctl changes.
|
|
111
122
|
It requires a Linux kernel with Landlock (5.13+; Ubuntu 22.04+, Debian 12+).
|
|
@@ -137,6 +148,20 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
137
148
|
| `--cert` | `VLAMBDA_CERT` | | TLS certificate path |
|
|
138
149
|
| `--key` | `VLAMBDA_KEY` | | TLS key path |
|
|
139
150
|
| | `VLAMBDA_REGISTRATION` | 1 | Allow public registration (`0` disables it) |
|
|
151
|
+
| | `VLAMBDA_SQLITE_JOURNAL` | auto | `wal` or `delete`; auto falls back to `delete` when CPython and system SQLite versions differ |
|
|
152
|
+
| | `VLAMBDA_RESP_CACHE_TTL` | 0 | GET response cache TTL in seconds (0 disables it) |
|
|
153
|
+
| | `VLAMBDA_CACHE_BACKEND` | memory | `memory`, `file` or `redis` for the optional response cache |
|
|
154
|
+
|
|
155
|
+
vlambda normally uses SQLite WAL. When CPython bundles a SQLite version
|
|
156
|
+
different from the system `libsqlite3` used by the V extension (for example on
|
|
157
|
+
Python 3.15), it automatically falls back to the rollback journal to avoid
|
|
158
|
+
cross-library WAL corruption. Set `VLAMBDA_SQLITE_JOURNAL=wal` or `delete` to
|
|
159
|
+
override it.
|
|
160
|
+
|
|
161
|
+
The GET response cache is disabled by default because a handler can depend on
|
|
162
|
+
headers, cookies, `request.env`, time or other request state. Enable it only for
|
|
163
|
+
stateless, idempotent GET lambdas; handlers that read request context, log,
|
|
164
|
+
`random` or `time.time` are skipped automatically.
|
|
140
165
|
|
|
141
166
|
## API
|
|
142
167
|
|
|
@@ -153,6 +178,8 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
153
178
|
- `GET /vlambda/<slug>` — Get lambda code
|
|
154
179
|
- `PUT /vlambda/<slug>?method=POST&name=new-name` — Update lambda
|
|
155
180
|
- `DELETE /vlambda/<slug>` — Delete lambda
|
|
181
|
+
- `GET /vlambda/<slug>/env` — List environment variables (secrets masked)
|
|
182
|
+
- `PUT /vlambda/<slug>/env` — Replace vars/secrets: `{"vars": {...}, "secrets": {...}}`
|
|
156
183
|
|
|
157
184
|
### API tokens (requires auth)
|
|
158
185
|
- `POST /tokens` — Create a token: `{"name":"ci","scopes":["read","write"]}`
|
|
@@ -198,6 +225,19 @@ Project exports include text files. Binary files are listed in
|
|
|
198
225
|
- `GET /vlambda/<slug>/packages` — List requirements
|
|
199
226
|
- `POST /vlambda/<slug>/packages` — Install PyPI packages into the vendor dir
|
|
200
227
|
|
|
228
|
+
### KV, egress and schedules
|
|
229
|
+
- `GET/PUT/DELETE /vlambda/<slug>/kv[/<key>]` — Read, write or delete KV entries
|
|
230
|
+
- `GET/PUT /vlambda/<slug>/egress` — Read or replace the egress allow-list
|
|
231
|
+
- `GET/POST /vlambda/<slug>/schedules` — List or create schedules
|
|
232
|
+
- `PUT/DELETE /vlambda/<slug>/schedules/<id>` — Update or delete a schedule
|
|
233
|
+
- `POST /vlambda/<slug>/schedules/<id>/run` — Run a schedule now
|
|
234
|
+
- `GET /vlambda/<slug>/schedules/<id>/runs` — Run history
|
|
235
|
+
|
|
236
|
+
### Metadata and OpenAPI
|
|
237
|
+
- `GET/PUT /vlambda/<slug>/meta` — Summary, tags and description
|
|
238
|
+
- `GET /openapi.json` — Owner-scoped OpenAPI 3.1 document
|
|
239
|
+
- `GET /docs` — Bundled OpenAPI viewer
|
|
240
|
+
|
|
201
241
|
### Monitoring (requires auth)
|
|
202
242
|
- `GET /health` — Health check
|
|
203
243
|
- `GET /ready` — Readiness
|
|
@@ -212,7 +252,7 @@ Project exports include text files. Binary files are listed in
|
|
|
212
252
|
- `GET /logs/history?days=N&slug=` — Persisted lambda logs
|
|
213
253
|
- `DELETE /logs/history?days=N&slug=` — Delete logs older than N days (`days=0` deletes all)
|
|
214
254
|
- `GET /pool/stats`, `GET /dlq`
|
|
215
|
-
- `POST /shutdown` — Graceful shutdown
|
|
255
|
+
- `POST /shutdown` — Graceful shutdown (requires `X-Admin-Token`)
|
|
216
256
|
|
|
217
257
|
## Logging
|
|
218
258
|
|
|
@@ -229,20 +269,49 @@ Logs are stored in the metrics database and can be queried with
|
|
|
229
269
|
`GET /logs/history?days=1&slug=<slug>`. The UI Logs view shows them alongside
|
|
230
270
|
invocations. The "Save logs" template in the editor is a ready-to-run example.
|
|
231
271
|
|
|
272
|
+
Metrics and logs are scoped to the authenticated user. The admin token
|
|
273
|
+
(`X-Admin-Token`) can query all users through the API/CLI.
|
|
274
|
+
|
|
232
275
|
Metrics and logs are pruned after `VLAMBDA_METRICS_RETENTION` days (default 7).
|
|
233
276
|
From the UI you can also prune data older than the selected period, or delete
|
|
234
277
|
all matching rows, with the current lambda filter applied.
|
|
235
278
|
|
|
236
279
|
## Lambda Format
|
|
237
280
|
|
|
238
|
-
Every lambda must define a `handler` function
|
|
281
|
+
Every lambda must define a `handler` function. The canonical contract returns a
|
|
282
|
+
`Response`; returning a `dict`, `str` or `bytes` is still accepted as shorthand:
|
|
239
283
|
|
|
240
284
|
```python
|
|
285
|
+
from vlambda import Response
|
|
286
|
+
|
|
241
287
|
def handler(request):
|
|
242
|
-
return
|
|
288
|
+
return Response.json(
|
|
289
|
+
{"msg": "hello", "path": request.path},
|
|
290
|
+
status=201,
|
|
291
|
+
headers={"X-Example": "yes"},
|
|
292
|
+
)
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
The `request` object has: `method`, `path`, `query_string`, `query`, `headers`,
|
|
296
|
+
`cookies`, `body`, `remote_ip`, `host`, `scheme`, `request_id`, `slug`, `env`,
|
|
297
|
+
and helpers `header()`, `json()`, `form()` and `log()`.
|
|
298
|
+
|
|
299
|
+
`Response` supports `json()`, `text()`, `html()`, `redirect()`, `no_content()`,
|
|
300
|
+
status codes, headers, cookies and binary bodies.
|
|
301
|
+
|
|
302
|
+
Handlers may also be coroutine functions. vlambda awaits the coroutine and
|
|
303
|
+
serializes its value exactly like a synchronous return:
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
async def double(value):
|
|
307
|
+
return value * 2
|
|
308
|
+
|
|
309
|
+
async def handler(request):
|
|
310
|
+
return {"values": [await double(n) for n in (1, 2, 3)]}
|
|
243
311
|
```
|
|
244
312
|
|
|
245
|
-
|
|
313
|
+
Await local coroutines or helpers you define with `async def`. The `asyncio`
|
|
314
|
+
module stays blocked because it exposes sockets indirectly.
|
|
246
315
|
|
|
247
316
|
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
317
|
|
|
@@ -252,13 +321,23 @@ Safe modules: `json`, `math`, `re`, `datetime`, `collections`, `itertools`, `fun
|
|
|
252
321
|
|
|
253
322
|
### Security
|
|
254
323
|
|
|
255
|
-
|
|
324
|
+
With the Docker default (`VLAMBDA_SANDBOX=fork`), user code runs in a fresh
|
|
325
|
+
runner process confined with Landlock and seccomp.
|
|
256
326
|
Landlock limits the filesystem to `/opt`, `/usr`, `/lib`, `/etc`, the current
|
|
257
327
|
project/vendor and a private temporary directory; `/data`, `/proc`, `/sys` and
|
|
258
|
-
the rest of the server cannot be read or listed. seccomp blocks
|
|
259
|
-
signals, `ptrace`, `mount`, namespace changes and
|
|
328
|
+
the rest of the server cannot be read or listed. seccomp blocks TCP/UDP and every
|
|
329
|
+
non-Unix socket, cross-process signals, `ptrace`, `mount`, namespace changes and
|
|
330
|
+
similar syscalls. Only `AF_UNIX` client sockets to the local capability broker
|
|
331
|
+
are allowed. Do not mount the Docker socket, cloud metadata proxies or other
|
|
332
|
+
privileged Unix sockets into the container: the sandbox needs Unix sockets for
|
|
333
|
+
the broker and cannot distinguish them from other local sockets. Resource
|
|
260
334
|
limits are applied too, and each invocation gets a fresh process.
|
|
261
335
|
|
|
336
|
+
The plain `python -m vlambda` command without `VLAMBDA_SANDBOX` uses the
|
|
337
|
+
in-process pool and is a development mode: lambdas run inside the server process
|
|
338
|
+
with only Python-level restrictions. Use `VLAMBDA_SANDBOX=fork` (Docker default),
|
|
339
|
+
`landlock`, `process` or `nsjail` for any untrusted code.
|
|
340
|
+
|
|
262
341
|
The Docker image keeps public registration open by default for toy deployments.
|
|
263
342
|
Set `VLAMBDA_REGISTRATION=0` to close it and create users with
|
|
264
343
|
`POST /admin/users` instead. A daily data reset removes state, but it does not
|
|
@@ -266,6 +345,179 @@ undo a kernel-level escape. Keep this deployment disposable and do not store
|
|
|
266
345
|
valuable secrets in it; for stronger isolation use gVisor, Firecracker or one
|
|
267
346
|
container per tenant.
|
|
268
347
|
|
|
348
|
+
## Environment and secrets
|
|
349
|
+
|
|
350
|
+
Set per-lambda variables with `PUT /vlambda/<slug>/env`:
|
|
351
|
+
|
|
352
|
+
```json
|
|
353
|
+
{
|
|
354
|
+
"vars": {"PLAIN": "hello"},
|
|
355
|
+
"secrets": {"TOKEN": "s3cret"}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Secrets are encrypted at rest, masked by the API and decrypted only for that
|
|
360
|
+
lambda's runner. Code lambdas read them from `request.env`; projects also see
|
|
361
|
+
them in `os.environ`. Use `VLAMBDA_ENCRYPTION_KEY` if you want to rotate
|
|
362
|
+
`VLAMBDA_SECRET` without losing existing secrets.
|
|
363
|
+
|
|
364
|
+
## KV store
|
|
365
|
+
|
|
366
|
+
Every lambda has a small persistent key/value store, isolated by lambda and
|
|
367
|
+
accessible through an allow-listed capability broker rather than a database
|
|
368
|
+
connection in the sandbox.
|
|
369
|
+
|
|
370
|
+
```python
|
|
371
|
+
def handler(request):
|
|
372
|
+
hits = request.kv.incr("hits")
|
|
373
|
+
request.kv.set("last", {"path": request.path}, ttl=3600)
|
|
374
|
+
return {"hits": hits, "last": request.kv.get("last")}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Projects use the same API with `from vlambda import kv`. Values can be strings,
|
|
378
|
+
numbers, booleans, null, JSON documents or bytes; `incr()` is atomic and `ttl`
|
|
379
|
+
is optional. Limits are 256 keys, 64 KiB per value and 1 MiB per lambda.
|
|
380
|
+
|
|
381
|
+
Management API (owner only, `X-Admin-Token` not needed):
|
|
382
|
+
|
|
383
|
+
- `GET /vlambda/<slug>/kv?prefix=` — list
|
|
384
|
+
- `GET /vlambda/<slug>/kv/<key>` — read
|
|
385
|
+
- `PUT /vlambda/<slug>/kv/<key>` — write `{"value": ..., "ttl": 3600}`
|
|
386
|
+
- `DELETE /vlambda/<slug>/kv/<key>` — delete one key
|
|
387
|
+
- `DELETE /vlambda/<slug>/kv` — clear the store
|
|
388
|
+
|
|
389
|
+
The UI exposes a KV card in the code and project editors.
|
|
390
|
+
|
|
391
|
+
## Egress
|
|
392
|
+
|
|
393
|
+
Lambdas cannot open TCP sockets. They can call allow-listed hostnames through
|
|
394
|
+
the capability broker:
|
|
395
|
+
|
|
396
|
+
```python
|
|
397
|
+
def handler(request):
|
|
398
|
+
response = request.fetch("https://api.example.com/items", timeout=5)
|
|
399
|
+
return {"status": response.status, "data": response.json()}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Projects use `from vlambda import fetch`. Supported methods are `GET`, `HEAD`,
|
|
403
|
+
`POST`, `PUT`, `PATCH` and `DELETE`; pass `data=` for raw bodies or
|
|
404
|
+
`json_payload=` for JSON. The response exposes `status`, `headers`, `body`,
|
|
405
|
+
`text` and `json()`.
|
|
406
|
+
|
|
407
|
+
Configure the allow-list per lambda (`GET/PUT /vlambda/<slug>/egress`):
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
python -m vlambda egress <slug> --set api.example.com --set "*.example.org"
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Matching is exact, or `*.example.org` for the apex and subdomains. HTTPS is
|
|
414
|
+
required by default; set `VLAMBDA_EGRESS_ALLOW_HTTP=1` for local development.
|
|
415
|
+
Private, loopback, link-local and reserved addresses are rejected; set
|
|
416
|
+
`VLAMBDA_EGRESS_ALLOW_PRIVATE=1` only for tests. Redirects are not followed.
|
|
417
|
+
Each invocation is limited to 20 calls, 1 MiB request bodies and 2 MiB
|
|
418
|
+
responses, with a 10 s maximum timeout. Denied hosts are logged without query
|
|
419
|
+
strings.
|
|
420
|
+
|
|
421
|
+
## Schedules
|
|
422
|
+
|
|
423
|
+
Create persistent cron jobs per lambda:
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
python -m vlambda schedule create <slug> --name nightly --cron "0 3 * * *" \
|
|
427
|
+
--method POST --path /schedule --payload '{"job": "cleanup"}'
|
|
428
|
+
python -m vlambda schedule list <slug>
|
|
429
|
+
python -m vlambda schedule run <slug> <id>
|
|
430
|
+
python -m vlambda schedule runs <slug> <id>
|
|
431
|
+
python -m vlambda schedule delete <slug> <id>
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Supported expressions use five fields (`minute hour day-of-month month weekday`),
|
|
435
|
+
with lists, ranges and steps, plus month/day names and IANA timezones. The
|
|
436
|
+
scheduler runs one leader per database lease; overlapping runs are skipped and
|
|
437
|
+
windows missed by more than `VLAMBDA_SCHEDULE_GRACE` seconds are recorded as
|
|
438
|
+
`missed`. Run history is retained for `VLAMBDA_SCHEDULE_RETENTION` days (7 by
|
|
439
|
+
default, max 1000 runs per schedule).
|
|
440
|
+
|
|
441
|
+
API:
|
|
442
|
+
|
|
443
|
+
- `GET/POST /vlambda/<slug>/schedules`
|
|
444
|
+
- `PUT/DELETE /vlambda/<slug>/schedules/<id>`
|
|
445
|
+
- `POST /vlambda/<slug>/schedules/<id>/run`
|
|
446
|
+
- `GET /vlambda/<slug>/schedules/<id>/runs`
|
|
447
|
+
|
|
448
|
+
The UI exposes a schedules card in the code and project editors.
|
|
449
|
+
|
|
450
|
+
## gVisor
|
|
451
|
+
|
|
452
|
+
For a second isolation boundary, run the container with the gVisor runtime:
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
docker run --runtime=runsc ... ghcr.io/rroblf01/vlambda:latest
|
|
456
|
+
# or merge the compose override:
|
|
457
|
+
docker compose -f docker/compose.yml -f docker/compose.gvisor.yml up -d
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Kubernetes uses `runtimeClassName: gvisor` on the pod. The internal fork +
|
|
461
|
+
Landlock + seccomp sandbox remains active. `scripts/gvisor-smoke.sh` builds the
|
|
462
|
+
image, runs the health check under `runsc` and skips cleanly when gVisor is not
|
|
463
|
+
installed. Firecracker/microVM-per-invocation is deferred to 0.5.0.
|
|
464
|
+
|
|
465
|
+
## High availability (single host)
|
|
466
|
+
|
|
467
|
+
0.4.0 supports multiple replicas on one host sharing a local `/data` volume.
|
|
468
|
+
SQLite WAL, a scheduler lease, task claiming and graceful drain keep scheduled
|
|
469
|
+
runs and tasks single-execution across replicas.
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
docker compose -f docker/compose.ha.yml up -d --build --scale vlambda=2
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
The sample puts nginx in front of two replicas. Do not place SQLite on NFS; use
|
|
476
|
+
a local volume on the same host. Multi-host HA needs an external database and is
|
|
477
|
+
deferred to 0.5.0.
|
|
478
|
+
|
|
479
|
+
Relevant settings:
|
|
480
|
+
|
|
481
|
+
- `VLAMBDA_INSTANCE_ID` — unique replica name (defaults to hostname:pid)
|
|
482
|
+
- `VLAMBDA_DRAIN_TIMEOUT` — graceful shutdown wait (seconds, default 20)
|
|
483
|
+
- `VLAMBDA_TASK_LEASE` — task claim lease (seconds, default 600)
|
|
484
|
+
- `VLAMBDA_SCHEDULE_GRACE` / `VLAMBDA_SCHEDULE_RETENTION` — cron behavior
|
|
485
|
+
- `/ready` returns `503` while a replica is draining
|
|
486
|
+
|
|
487
|
+
## OpenAPI
|
|
488
|
+
|
|
489
|
+
Every lambda can carry `summary`, `tags` and `description` metadata, editable
|
|
490
|
+
from the code/project editor or `PUT /vlambda/<slug>/meta`. The generated spec is
|
|
491
|
+
available at `/openapi.json` (authenticated and owner-scoped by default; set
|
|
492
|
+
`VLAMBDA_OPENAPI_PUBLIC=1` for a public spec) and a lightweight viewer is served
|
|
493
|
+
at `/docs` without external assets.
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
python -m vlambda openapi --out openapi.json
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
The spec describes `/f/<slug>` for every owned lambda, its method, request body
|
|
500
|
+
for write methods, generic JSON/text/binary responses and the `X-Request-Id`
|
|
501
|
+
header. Project static files are described under `/f/<slug>/{path}`.
|
|
502
|
+
|
|
503
|
+
## CLI
|
|
504
|
+
|
|
505
|
+
The CLI talks to a running server and uses `VLAMBDA_URL`/`VLAMBDA_TOKEN` or
|
|
506
|
+
`--url`/`--token`:
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
python -m vlambda deploy main.py --name my-lambda --method GET
|
|
510
|
+
python -m vlambda invoke <slug>
|
|
511
|
+
python -m vlambda logs --slug <slug> --days 1
|
|
512
|
+
python -m vlambda env <slug> --set PLAIN=hello --secret TOKEN=s3cret
|
|
513
|
+
python -m vlambda kv <slug> --set hits=0 --ttl 3600
|
|
514
|
+
python -m vlambda kv <slug> --get hits
|
|
515
|
+
python -m vlambda egress <slug> --set api.example.com
|
|
516
|
+
python -m vlambda schedule list <slug>
|
|
517
|
+
python -m vlambda openapi --out openapi.json
|
|
518
|
+
python -m vlambda task <task-id>
|
|
519
|
+
```
|
|
520
|
+
|
|
269
521
|
## Web UI
|
|
270
522
|
|
|
271
523
|
Open http://localhost:8080/ in your browser for the dashboard:
|
|
@@ -301,9 +553,10 @@ For a disposable demo, run it from cron every day:
|
|
|
301
553
|
| Metric | Value |
|
|
302
554
|
|--------|-------|
|
|
303
555
|
| Cold start | 0ms in persistent mode; fresh sandbox process in Docker |
|
|
304
|
-
| Warm invocation | ~0.3ms |
|
|
305
|
-
|
|
|
306
|
-
| Throughput (
|
|
556
|
+
| Warm invocation (in-process) | ~0.3ms |
|
|
557
|
+
| Warm invocation (Docker fork sandbox) | ~10-20ms p50 |
|
|
558
|
+
| Throughput (concurrent, free-threaded) | ~3,000 req/s in-process |
|
|
559
|
+
| Response cache | Opt-in via `VLAMBDA_RESP_CACHE_TTL`; ~100x faster for stateless GETs |
|
|
307
560
|
|
|
308
561
|
## Architecture
|
|
309
562
|
|