pub trait JournalWriter: Send + Sync {
// Required methods
fn append_transition(
&self,
received_ts_ms: u64,
command_data: &[u8],
response_data: Option<&[u8]>,
order_id: Option<i64>,
pre_digest: &EngineStateDigest,
post_digest: &EngineStateDigest,
duration_ms: u64,
events: &[EngineMessage],
request_uuid: DbUuid,
command_type_enum: Option<CommandType>,
) -> Result<JournalAppendResult, EngineJournalError>;
fn get_by_request_id(
&self,
request_id: &Uuid,
) -> Result<Option<JournalFullRecord>, EngineJournalError>;
fn request_id_exists(
&self,
request_id: &Uuid,
) -> Result<bool, EngineJournalError>;
fn get_recent_request_ids(
&self,
since_hours: i64,
) -> Result<HashSet<Uuid>, EngineJournalError>;
fn get_recent(
&self,
limit: usize,
) -> Result<Vec<JournalCommandSummary>, EngineJournalError>;
// Provided methods
fn is_durable(&self) -> bool { ... }
fn append_transition_with_fill_side_effects(
&self,
received_ts_ms: u64,
command_data: &[u8],
response_data: Option<&[u8]>,
order_id: Option<i64>,
pre_digest: &EngineStateDigest,
post_digest: &EngineStateDigest,
duration_ms: u64,
events: &[EngineMessage],
fill_side_effects: &[JournalFillSideEffect],
balance_updates: &[BalanceUpdate],
request_uuid: DbUuid,
command_type_enum: Option<CommandType>,
) -> Result<JournalAppendResult, EngineJournalError> { ... }
}Expand description
Trait for journal writers (enables mock implementations for testing)
Required Methods§
Sourcefn append_transition(
&self,
received_ts_ms: u64,
command_data: &[u8],
response_data: Option<&[u8]>,
order_id: Option<i64>,
pre_digest: &EngineStateDigest,
post_digest: &EngineStateDigest,
duration_ms: u64,
events: &[EngineMessage],
request_uuid: DbUuid,
command_type_enum: Option<CommandType>,
) -> Result<JournalAppendResult, EngineJournalError>
fn append_transition( &self, received_ts_ms: u64, command_data: &[u8], response_data: Option<&[u8]>, order_id: Option<i64>, pre_digest: &EngineStateDigest, post_digest: &EngineStateDigest, duration_ms: u64, events: &[EngineMessage], request_uuid: DbUuid, command_type_enum: Option<CommandType>, ) -> Result<JournalAppendResult, EngineJournalError>
Append a state transition to the journal. Returns existing record if request_id already exists (idempotency).
Sourcefn get_by_request_id(
&self,
request_id: &Uuid,
) -> Result<Option<JournalFullRecord>, EngineJournalError>
fn get_by_request_id( &self, request_id: &Uuid, ) -> Result<Option<JournalFullRecord>, EngineJournalError>
Get a journal record by request_id
Sourcefn request_id_exists(
&self,
request_id: &Uuid,
) -> Result<bool, EngineJournalError>
fn request_id_exists( &self, request_id: &Uuid, ) -> Result<bool, EngineJournalError>
Check if a request_id exists in the journal (lightweight existence check)
Sourcefn get_recent_request_ids(
&self,
since_hours: i64,
) -> Result<HashSet<Uuid>, EngineJournalError>
fn get_recent_request_ids( &self, since_hours: i64, ) -> Result<HashSet<Uuid>, EngineJournalError>
Get recent request_ids for idempotency cache warm-up
Sourcefn get_recent(
&self,
limit: usize,
) -> Result<Vec<JournalCommandSummary>, EngineJournalError>
fn get_recent( &self, limit: usize, ) -> Result<Vec<JournalCommandSummary>, EngineJournalError>
Get recent journal command summaries (for monitoring)
Provided Methods§
Sourcefn is_durable(&self) -> bool
fn is_durable(&self) -> bool
Whether writes through this writer survive process restart.
Sourcefn append_transition_with_fill_side_effects(
&self,
received_ts_ms: u64,
command_data: &[u8],
response_data: Option<&[u8]>,
order_id: Option<i64>,
pre_digest: &EngineStateDigest,
post_digest: &EngineStateDigest,
duration_ms: u64,
events: &[EngineMessage],
fill_side_effects: &[JournalFillSideEffect],
balance_updates: &[BalanceUpdate],
request_uuid: DbUuid,
command_type_enum: Option<CommandType>,
) -> Result<JournalAppendResult, EngineJournalError>
fn append_transition_with_fill_side_effects( &self, received_ts_ms: u64, command_data: &[u8], response_data: Option<&[u8]>, order_id: Option<i64>, pre_digest: &EngineStateDigest, post_digest: &EngineStateDigest, duration_ms: u64, events: &[EngineMessage], fill_side_effects: &[JournalFillSideEffect], balance_updates: &[BalanceUpdate], request_uuid: DbUuid, command_type_enum: Option<CommandType>, ) -> Result<JournalAppendResult, EngineJournalError>
Append a transition while atomically materializing any fill side-effects.
Writers that do not own durable fill persistence can ignore the side-effects
and fall back to append_transition.