pub struct OutboxProcessor<S, T, P>{ /* 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>
impl<S, T, P> OutboxProcessor<S, T, P>
Sourcepub fn new(
storage: Arc<S>,
publisher: Arc<T>,
config: Arc<OutboxConfig<P>>,
) -> Self
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.
Sourcepub async fn process_pending_events(&self) -> Result<usize, OutboxError>
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.