prefect server in zig

messaging#

inter-component communication via messaging.zig.

bounded channel#

generic thread-safe queue with backpressure:

pub fn BoundedChannel(comptime T: type, comptime capacity: usize) type

operations:

  • trySend() - non-blocking, returns false if full
  • receiveTimeout() - blocking with timeout
  • drain() - batch receive up to N items
  • close() - signal shutdown, wake waiters

event channel#

global channel for event ingestion:

pub const EventChannel = BoundedChannel(StoredEvent, 50000);

50k capacity matches python prefect's backpressure limit. dropped events logged with periodic sampling.

usage#

producers call publishEvent(), consumers get channel via getEventChannel().

future#

current implementation is in-memory. interface designed to support:

  • redis streams
  • kafka

swap implementation without changing producer/consumer code.