prefect server in zig

services#

background workers managed by services/mod.zig.

registry#

simple array of function pointers:

pub const Service = struct {
    name: []const u8,
    start: *const fn () anyerror!void,
    stop: *const fn () void,
};

const all = [_]Service{
    .{ .name = "event_persister", .start = event_persister.start, .stop = event_persister.stop },
};

startAll() iterates forward, stopAll() iterates reverse.

event_persister#

drains events from the messaging channel and writes to sqlite.

  • batch size: 100 events
  • flush interval: 1 second
  • deduplication: INSERT OR IGNORE by event id
  • retention: 7 days, trimmed hourly

lifecycle: spawns worker thread on start(), signals and joins on stop().