Skip to main content

CommandJournalWriter

Trait CommandJournalWriter 

Source
pub trait CommandJournalWriter: Send + Sync {
    // Required methods
    fn begin<'life0, 'async_trait>(
        &'life0 self,
        entry: CommandJournalEntry,
    ) -> Pin<Box<dyn Future<Output = Result<JournalAdmission, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn mark_executing<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        account: &'life1 AccountId,
        command_id: &'life2 CommandId,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn complete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        account: &'life1 AccountId,
        command_id: &'life2 CommandId,
        outcome: JournalOutcome,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn fail<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        account: &'life1 AccountId,
        command_id: &'life2 CommandId,
        error: &'life3 ExecutionError,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

The write half of the command journal (spec §22.1).

Required Methods§

Source

fn begin<'life0, 'async_trait>( &'life0 self, entry: CommandJournalEntry, ) -> Pin<Box<dyn Future<Output = Result<JournalAdmission, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Admits a command under UNIQUE (account_id, idempotency_key).

The entry is persisted as given (normally Pending) when the key is new. When the key exists, nothing is written and the persisted entry is returned as JournalAdmission::Replay, whatever its status.

§Errors
  • Conflict when command_id already exists for the account under another idempotency key.
Source

fn mark_executing<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, account: &'life1 AccountId, command_id: &'life2 CommandId, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Moves Pending → Executing. Calling it on an Executing entry is accepted without change.

§Errors
  • NotFound when the entry does not exist for account.
  • Conflict when the status is neither Pending nor Executing.
Source

fn complete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, account: &'life1 AccountId, command_id: &'life2 CommandId, outcome: JournalOutcome, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Records the outcome and moves the entry to JournalOutcome::status. Recording the same outcome again on an entry already in that status is accepted without change.

§Errors
  • NotFound when the entry does not exist for account.
  • Conflict when the transition is illegal or a different outcome is already recorded.

Provided Methods§

Source

fn fail<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, account: &'life1 AccountId, command_id: &'life2 CommandId, error: &'life3 ExecutionError, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Records an execution error as the outcome, through JournalOutcome::from_execution_error. Same rules as Self::complete.

The default body is the whole contract; override it only to save a round trip, and keep the mapping identical.

§Errors

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§