prefect server in zig
at main 66 lines 2.2 kB view raw view rendered
1# zig compatibility notes 2 3comparison of zig implementation with python prefect server. 4 5## RetryFailedFlows 6 7### matching behavior ✓ 8 9| aspect | python | zig | 10|--------|--------|-----| 11| from_states | {RUNNING} | StateTypeSet.init(&.{.RUNNING}) | 12| to_states | {FAILED} | StateTypeSet.init(&.{.FAILED}) | 13| retry check | `retries is None or run_count > retries` | `ctx.retries orelse return; if (ctx.run_count > max_retries) return;` | 14| scheduled time | `now + timedelta(seconds=retry_delay or 0)` | `now_us + delay_seconds * 1_000_000` | 15| retry state | `AwaitingRetry` (SCHEDULED) | `SCHEDULED` with name "AwaitingRetry" | 16| response | `reject_transition(state, reason="Retrying")` | `REJECT` status | 17 18### implemented ✓ 19 20| behavior | status | 21|----------|--------| 22| retry_type = "in_process" on retry | ✓ via `set_retry_type_in_process` flag | 23| resuming = false on retry | ✓ via `set_resuming_false` flag | 24| pause_keys = [] on retry | ✓ via `clear_pause_keys` flag | 25| retry_type = null when exhausted | ✓ via `clear_retry_type` flag | 26 27### not needed 28 29- **old client compatibility** (API < 0.8.3): python resets failed task runs to AwaitingRetry state - not needed for new clients 30 31## schema compatibility 32 33### empirical_policy JSON 34 35python schema: 36```json 37{ 38 "retries": int | null, 39 "retry_delay": int | null, 40 "pause_keys": [], 41 "resuming": false, 42 "retry_type": null | "in_process" | "reschedule", 43 "max_retries": 0, // deprecated 44 "retry_delay_seconds": 0 // deprecated 45} 46``` 47 48zig reads: `retries`, `retry_delay` from this JSON 49zig stores: as TEXT (sqlite) or JSONB (postgres) - compatible 50 51### storage types 52 53| column | postgres python | postgres zig | sqlite python | sqlite zig | 54|--------|-----------------|--------------|---------------|------------| 55| id | UUID | UUID | CHAR(36) | CHAR(36) | 56| timestamps | TIMESTAMP(tz) | TIMESTAMP(tz) | DATETIME | DATETIME | 57| empirical_policy | JSONB | JSONB | JSON | TEXT | 58 59## migration path 60 61our zig server stores data compatible with python prefect server: 62- UUIDs as standard format 63- timestamps as ISO 8601 UTC 64- JSON/JSONB for policy fields 65 66data created by zig server can be read by python server (and vice versa).