prefect server in zig
1# messaging
2
3inter-component communication via `messaging.zig`.
4
5## bounded channel
6
7generic thread-safe queue with backpressure:
8
9```zig
10pub fn BoundedChannel(comptime T: type, comptime capacity: usize) type
11```
12
13operations:
14- `trySend()` - non-blocking, returns false if full
15- `receiveTimeout()` - blocking with timeout
16- `drain()` - batch receive up to N items
17- `close()` - signal shutdown, wake waiters
18
19## event channel
20
21global channel for event ingestion:
22
23```zig
24pub const EventChannel = BoundedChannel(StoredEvent, 50000);
25```
26
2750k capacity matches python prefect's backpressure limit. dropped events logged with periodic sampling.
28
29## usage
30
31producers call `publishEvent()`, consumers get channel via `getEventChannel()`.
32
33## future
34
35current implementation is in-memory. interface designed to support:
36- redis streams
37- kafka
38
39swap implementation without changing producer/consumer code.