pub struct DurableConversation { /* private fields */ }Expand description
Haematite-backed event-sourced durable conversation.
Implementations§
Source§impl DurableConversation
impl DurableConversation
Sourcepub fn new(
conversation_id: impl Into<String>,
store: Arc<dyn DurableStore>,
) -> Self
pub fn new( conversation_id: impl Into<String>, store: Arc<dyn DurableStore>, ) -> Self
Creates a new durable conversation with empty replay state and expected sequence zero.
Sourcepub async fn recover(
conversation_id: impl Into<String>,
store: Arc<dyn DurableStore>,
) -> Result<Self, DurabilityError>
pub async fn recover( conversation_id: impl Into<String>, store: Arc<dyn DurableStore>, ) -> Result<Self, DurabilityError>
Recovers a durable conversation by replaying its full event log from sequence zero.
§Errors
Propagates store read errors, event deserialization errors, and sequence overflow.
Sourcepub fn conversation_id(&self) -> &str
pub fn conversation_id(&self) -> &str
Returns the conversation stream key used for all appends and replay reads.
Sourcepub const fn state(&self) -> &ConversationState
pub const fn state(&self) -> &ConversationState
Returns the current replay-derived state.
Sourcepub const fn expected_seq(&self) -> u64
pub const fn expected_seq(&self) -> u64
Returns the next expected sequence used for optimistic append concurrency.
Sourcepub async fn receive_message(
&mut self,
message_id: impl Into<String>,
received_at: u64,
) -> Result<RedeliveryDecision, DurabilityError>
pub async fn receive_message( &mut self, message_id: impl Into<String>, received_at: u64, ) -> Result<RedeliveryDecision, DurabilityError>
Handles a message delivery using replay-derived duplicate detection.
§Errors
Returns serialization or store append errors for never-seen messages, and returns
DurabilityError::ConfigError if a partial message cannot advance its step index.
Sourcepub async fn record_message_received(
&mut self,
message_id: impl Into<String>,
received_at: u64,
) -> Result<u64, DurabilityError>
pub async fn record_message_received( &mut self, message_id: impl Into<String>, received_at: u64, ) -> Result<u64, DurabilityError>
Appends a MessageReceived event using the current expected sequence.
§Errors
Propagates event serialization errors and all store append errors, including
DurabilityError::SequenceConflict without retrying.
Sourcepub async fn record_processing_started(
&mut self,
message_id: impl Into<String>,
) -> Result<u64, DurabilityError>
pub async fn record_processing_started( &mut self, message_id: impl Into<String>, ) -> Result<u64, DurabilityError>
Appends a ProcessingStarted event using the current expected sequence.
§Errors
Propagates event serialization errors and all store append errors, including
DurabilityError::SequenceConflict without retrying.
Sourcepub async fn record_step_completed(
&mut self,
message_id: impl Into<String>,
step_index: u32,
output: Vec<u8>,
) -> Result<u64, DurabilityError>
pub async fn record_step_completed( &mut self, message_id: impl Into<String>, step_index: u32, output: Vec<u8>, ) -> Result<u64, DurabilityError>
Appends a StepCompleted event using the current expected sequence.
§Errors
Propagates event serialization errors and all store append errors, including
DurabilityError::SequenceConflict without retrying.
Sourcepub async fn record_processing_finished(
&mut self,
message_id: impl Into<String>,
) -> Result<u64, DurabilityError>
pub async fn record_processing_finished( &mut self, message_id: impl Into<String>, ) -> Result<u64, DurabilityError>
Appends a ProcessingFinished event using the current expected sequence.
§Errors
Propagates event serialization errors and all store append errors, including
DurabilityError::SequenceConflict without retrying.
Sourcepub async fn record_error(
&mut self,
message_id: impl Into<String>,
error: impl Into<String>,
) -> Result<u64, DurabilityError>
pub async fn record_error( &mut self, message_id: impl Into<String>, error: impl Into<String>, ) -> Result<u64, DurabilityError>
Appends an ErrorOccurred event using the current expected sequence.
§Errors
Propagates event serialization errors and all store append errors, including
DurabilityError::SequenceConflict without retrying.
Trait Implementations§
Source§impl Clone for DurableConversation
impl Clone for DurableConversation
Source§fn clone(&self) -> DurableConversation
fn clone(&self) -> DurableConversation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more