1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Outbox Worker - Drains and publishes outbox messages.
//!
//! This module provides the worker infrastructure for processing outbox messages:
//! - `OutboxStore` - Store operations for claiming and completing messages
//! - `OutboxWorker` - Synchronous message processor
//! - `OutboxPublisher` - Trait for publishing to external systems
//! - `LogPublisher` - Simple logging publisher for testing
//! - `LocalEmitterPublisher` - In-process event emitter (requires `emitter` feature)
//!
//! ## Separation of Concerns
//!
//! The outbox pattern has two distinct phases:
//! 1. **Commit phase** (see `outbox` module) - Atomically commit aggregate + outbox message
//! 2. **Worker phase** (this module) - Drain outbox and publish to external systems
//!
//! ## Example
//!
//! ```ignore
//! use distributed::{ClaimOutboxMessages, OutboxClaimRef, OutboxStore, OutboxWorker, LogPublisher};
//! use std::time::Duration;
//!
//! // Claim pending messages
//! let worker_id = "worker-1";
//! let messages = outbox.claim(ClaimOutboxMessages::new(worker_id, 10, Duration::from_secs(60)))?;
//!
//! // Process with a worker
//! let mut worker = OutboxWorker::new(LogPublisher::default()).with_worker_id(worker_id);
//! for mut msg in messages {
//! let claim = OutboxClaimRef::from_message(&msg)?;
//! let result = worker.process_message(&mut msg)?;
//! if result.completed {
//! outbox.complete(&claim)?;
//! } else if result.released || result.failed {
//! let error = msg.last_error.as_deref().unwrap_or("publish failed");
//! outbox.record_failure(&claim, error, 3)?;
//! }
//! }
//! ```
// Publishers
pub use LocalEmitterPublisher;
pub use ;
// Repository helpers
pub use ensure_active_claim;
pub use ;
// Worker
pub use ;
// Outbox -> bus bridge (moved out of the bus module; depends up on bus traits).
pub use BusPublisher;
pub use ;
pub use ;
pub use BusOutboxPublishHook;