Skip to main content

FastPublisherBuilder

Struct FastPublisherBuilder 

Source
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 = 2
  • gap_mode = Fail
  • ack_timeout = <JetStream context default>

Implementations§

Source§

impl FastPublisherBuilder

Source

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.

Source

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.

  • 1 behaves like synchronous async publish throttled to flow N
  • 2 is the ADR-50 recommended default (optimal for most cases)
  • 3 is useful on higher-RTT links

Values outside the range are returned as an error from build.

Source

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.

Source

pub fn gap_mode(self, mode: GapMode) -> Self

Set the gap handling mode. Default: GapMode::Fail.

Source

pub fn on_error<F>(self, handler: F) -> Self
where F: FnMut(FastPublishError) + Send + 'static,

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.

Source

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more