Skip to main content

TransactionalOutbox

Trait TransactionalOutbox 

Source
pub trait TransactionalOutbox {
    type Aggregate: AggregateRoot;
    type Error;

    // Required methods
    fn save_and_enqueue(
        &mut self,
        aggregate: &Self::Aggregate,
        expected: ExpectedRevision,
        events: Vec<<Self::Aggregate as AggregateRoot>::Event>,
    ) -> Result<AppendResult, AppendError<Self::Error>>;
    fn claim(
        &mut self,
    ) -> Result<Option<OutboxClaim<<Self::Aggregate as AggregateRoot>::Event>>, Self::Error>;
    fn acknowledge(
        &mut self,
        message_id: &OutboxMessageId,
    ) -> Result<(), Self::Error>;
}
Expand description

English:
Persistence boundary for saving an aggregate and staging events for delivery.

An adapter supplies the transaction joining aggregate persistence and outbox insertion; this trait contains no transaction implementation. Adapters must describe atomicity, durability, concurrent claims, claim order, retry/lease policy, and panic conditions. Claiming and acknowledging are separate from saving; no exactly-once delivery mechanism is supplied, so consumers may need to handle duplicate events.

日本語:
集約の保存と配信対象イベントの登録を行う永続化境界です。

集約の永続化とアウトボックス挿入を結ぶトランザクションはアダプターが提供し、 このトレイト自体には実装しません。原子性、永続性、並行取得、取得順序、再試行・ リース方針、パニック条件はアダプターが記述する必要があります。取得と確認応答は 保存から分離されています。厳密に一度だけ配信する機構は提供しないため、 コンシューマー側で重複イベントへの対応が必要になる場合があります。

Required Associated Types§

Source

type Aggregate: AggregateRoot

English:
Aggregate whose state and associated events are staged together.

日本語:
状態と関連イベントをまとめて登録する対象の集約です。

Source

type Error

English:
Adapter failure used by save, claim, and acknowledgement operations.

日本語:
保存、取得、確認応答が使うアダプター障害です。

Required Methods§

Source

fn save_and_enqueue( &mut self, aggregate: &Self::Aggregate, expected: ExpectedRevision, events: Vec<<Self::Aggregate as AggregateRoot>::Event>, ) -> Result<AppendResult, AppendError<Self::Error>>

English:
Borrows aggregate and consumes events to save and enqueue under expected. Returns the resulting stream revision, or AppendError for an empty batch, conflict, revision exhaustion, or adapter failure. Events are supplied explicitly; this signature does not pull or clear the aggregate’s pending events. The batch is not returned on error; consult the adapter’s transaction contract before retrying.

日本語:
aggregate を借用し、events を消費して expected を条件に保存・登録します。 結果のストリームリビジョン、または空バッチ、競合、リビジョン枯渇、アダプター障害を 示す AppendError を返します。イベントは明示的に渡します。このシグネチャは 集約の保留イベントを取り出したり消去したりしません。エラー時にバッチは返されないため、 再試行する前にアダプターのトランザクション契約を確認してください。

Source

fn claim( &mut self, ) -> Result<Option<OutboxClaim<<Self::Aggregate as AggregateRoot>::Event>>, Self::Error>

English:
Claims an available message, returning its owned identifier and event. Ok(None) means no message is available to this call; adapter failures use Self::Error. Reservation duration and eligibility for redelivery are not represented by OutboxClaim.

日本語:
利用可能なメッセージを取得し、所有された識別子とイベントを返します。 Ok(None) はこの呼び出しで取得できるものがないことを表し、障害は Self::Error です。 予約期間と再配信の条件は OutboxClaim では表現しません。

Source

fn acknowledge( &mut self, message_id: &OutboxMessageId, ) -> Result<(), Self::Error>

English:
Reports completed handling of message_id, returning an adapter error on failure. Unknown IDs, repeated acknowledgements, and removal or retention of acknowledged messages follow the adapter’s policy. No claim token or ownership proof is required by this API.

日本語:
message_id の処理完了を通知し、失敗時にアダプターエラーを返します。 未知の識別子、確認応答の繰り返し、応答済みメッセージの削除・保持はアダプターの 方針に従います。この API は取得トークンや所有権の証明を要求しません。

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§