Skip to main content

OutboxProcessor

Struct OutboxProcessor 

Source
pub struct OutboxProcessor<S, T, P>
where P: Debug + Clone + Serialize,
{ /* private fields */ }
Expand description

Processes one batch of pending outbox events per invocation.

Holds handles to storage, transport, and configuration; the manager constructs a single processor at startup and reuses it across iterations.

Implementations§

Source§

impl<S, T, P> OutboxProcessor<S, T, P>
where S: OutboxStorage<P> + 'static, T: Transport<P> + 'static, P: Debug + Clone + Serialize + Send + Sync,

Source

pub fn new( storage: Arc<S>, publisher: Arc<T>, config: Arc<OutboxConfig<P>>, ) -> Self

Creates a processor wired to the supplied storage, transport, and configuration.

Source

pub async fn process_pending_events(&self) -> Result<usize, OutboxError>

Processes one batch of pending events.

Fetches up to config.batch_size rows via OutboxStorage::fetch_next_to_process, publishes each through the Transport, and then marks every successfully published row as Sent in a single update_status call. Rows whose publish call failed are left in Processing; their lock will expire and make them eligible for retry.

Returns the number of events fetched in the batch — 0 signals to the caller (typically the manager’s drain loop) that there is nothing left to do right now and it can go back to waiting.

When the dlq feature is enabled, takes a shared DlqHeap and records success or failure per event so the heap can track repeat-offender rows.

§Errors

Returns a DatabaseError propagated from fetch_next_to_process or update_status. Per-event publish failures are not propagated — they are logged via tracing::error! and the rest of the batch continues.

Auto Trait Implementations§

§

impl<S, T, P> Freeze for OutboxProcessor<S, T, P>

§

impl<S, T, P> RefUnwindSafe for OutboxProcessor<S, T, P>

§

impl<S, T, P> Send for OutboxProcessor<S, T, P>
where S: Sync + Send, T: Sync + Send,

§

impl<S, T, P> Sync for OutboxProcessor<S, T, P>
where S: Sync + Send, T: Sync + Send,

§

impl<S, T, P> Unpin for OutboxProcessor<S, T, P>

§

impl<S, T, P> UnsafeUnpin for OutboxProcessor<S, T, P>

§

impl<S, T, P> UnwindSafe for OutboxProcessor<S, T, P>

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, 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<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