Skip to main content

appletheia_application/outbox/command/
command_outbox.rs

1use super::{CommandEnvelope, CommandOutboxId};
2use crate::messaging::PublishDispatchError;
3use crate::outbox::{OrderingKey, Outbox, OutboxLifecycle, OutboxState};
4
5#[derive(Clone, Debug, Eq, PartialEq)]
6pub struct CommandOutbox {
7    pub id: CommandOutboxId,
8    pub sequence: i64,
9    pub command: CommandEnvelope,
10    pub state: OutboxState,
11    pub last_error: Option<PublishDispatchError>,
12    pub lifecycle: OutboxLifecycle,
13}
14
15impl Outbox for CommandOutbox {
16    type Id = CommandOutboxId;
17    type Message = CommandEnvelope;
18
19    fn id(&self) -> Self::Id {
20        self.id
21    }
22
23    fn ordering_key(&self) -> OrderingKey {
24        OrderingKey::from(self.command.correlation_id)
25    }
26
27    fn message(&self) -> &Self::Message {
28        &self.command
29    }
30
31    fn state(&self) -> &OutboxState {
32        &self.state
33    }
34
35    fn state_mut(&mut self) -> &mut OutboxState {
36        &mut self.state
37    }
38
39    fn last_error(&self) -> &Option<PublishDispatchError> {
40        &self.last_error
41    }
42
43    fn last_error_mut(&mut self) -> &mut Option<PublishDispatchError> {
44        &mut self.last_error
45    }
46
47    fn lifecycle(&self) -> &OutboxLifecycle {
48        &self.lifecycle
49    }
50
51    fn lifecycle_mut(&mut self) -> &mut OutboxLifecycle {
52        &mut self.lifecycle
53    }
54}