Skip to main content

EventPublisherFn

Type Alias EventPublisherFn 

Source
pub type EventPublisherFn<A> = fn(consumer: Consumer<OutputSlot<<A as Application>::Report, <A as Application>::QueryResponse>>, bind_addr: SocketAddr, authorized_keys: Arc<AuthorizedKeys>, shutdown: &AtomicBool, wait: WaitStrategy);
Expand description

Body of the event-publisher thread: a free function with this exact signature (an application with an output feed supplies its publisher; one without supplies nothing). Passing it as a function pointer keeps the runtime decoupled from the application — no application reference inside server.rs — without paying for a boxed closure.

Threaded into run (and run_dpdk under feature = "dpdk") as Option<EventPublisherFn>: None disables the publisher unconditionally, Some(_) wires it up when --event-bind is also set.

The consumer trails the response stage: it yields a slot only once the response stage has passed it through the durability gate, so every slot it yields belongs to an event that holds the copies the ack policy demands: a report the publisher sees is exactly as durable as the reply its client was given. While the policy cannot be satisfied (the replicas it needs are gone), the consumer yields nothing, as the clients get no replies; the publisher must observe shutdown on its own while it waits, not on a new slot arriving.

Stamp each published frame with the slot’s wire sequence (OutputSlot::wire_seq), the event’s position in the journal: stable across restarts and failovers, so a subscriber can key on it to resume or deduplicate. The consumer’s own position in the output ring is not: it restarts at every boot.

The consumer also yields the ack-policy changes the journal records (OutputPayload::AckPolicyChange), at their place in the order. They carry no application output: skip them, or publish them to subscribers that audit the cluster’s durability.