pub struct FastPublisherBuilder { /* private fields */ }Expand description
Builder for a FastPublisher.
Obtained via FastPublishExt::fast_publish. Call build
to validate configuration and produce a ready-to-use publisher.
All setters are optional; defaults match ADR-50 recommendations:
flow = 100(ack every 100 messages ceiling)max_outstanding_acks = 2gap_mode = Failack_timeout = <JetStream context default>
Implementations§
Source§impl FastPublisherBuilder
impl FastPublisherBuilder
Sourcepub fn flow(self, flow: u16) -> Self
pub fn flow(self, flow: u16) -> Self
Set the client-requested maximum flow — the upper bound on how often the server will send flow acks. The server may choose a lower effective flow.
Must be at least 1. Values of 0 are clamped to 1.
Sourcepub fn max_outstanding_acks(self, n: u16) -> Self
pub fn max_outstanding_acks(self, n: u16) -> Self
Set the number of flow-ack-batches that can be in flight before the
publisher stalls and waits for an ack. Valid range is 1..=3.
1behaves like synchronous async publish throttled to flow N2is the ADR-50 recommended default (optimal for most cases)3is useful on higher-RTT links
Values outside the range are returned as an error from build.
Sourcepub fn ack_timeout(self, timeout: Duration) -> Self
pub fn ack_timeout(self, timeout: Duration) -> Self
Set the timeout for waiting on flow acks and the final commit ack.
When the publisher is stalled waiting for an ack, it will auto-send
pings every ack_timeout / 3 to recover from lost acks, giving up
after the full ack_timeout elapses.
Sourcepub fn gap_mode(self, mode: GapMode) -> Self
pub fn gap_mode(self, mode: GapMode) -> Self
Set the gap handling mode. Default: GapMode::Fail.
Sourcepub fn on_error<F>(self, handler: F) -> Self
pub fn on_error<F>(self, handler: F) -> Self
Register a callback invoked for asynchronous events: gap detections, per-message flow errors, and server-side fast-batch errors.
The callback is called on the publisher’s task synchronously from the
middle of add / commit / close, so it must be fast and
non-blocking.
Sourcepub fn build(self) -> Result<FastPublisher, FastPublishError>
pub fn build(self) -> Result<FastPublisher, FastPublishError>
Validate configuration and produce a FastPublisher.
The subscription to the batch inbox is NOT created here — it is lazily
opened on the first add / commit / close. This matches the Go
reference implementation and avoids wasted subscriptions when a
publisher is built and then dropped unused.
§Errors
FastPublishErrorKind::InvalidConfigifmax_outstanding_acksis outside1..=3.FastPublishErrorKind::InvalidInboxShapeif the client’snew_inbox()does not produce a two-token inbox (required by the server’s reply-subject parser).