Skip to main content

AsyncIdempotentProjection

Trait AsyncIdempotentProjection 

Source
pub trait AsyncIdempotentProjection: Send {
    type Event: DomainEvent + Sync;
    type Cursor: Send + Sync;
    type Error: Send;

    // Required method
    fn apply_once<'a>(
        &'a mut self,
        event: &'a Self::Event,
        checkpoint: &'a ProjectionCheckpoint<Self::Cursor>,
    ) -> Pin<Box<dyn Future<Output = Result<ProjectionApplication, Self::Error>> + Send + 'a>>;
}
Expand description

English:
Asynchronous duplicate-aware projection independent of crate::AsyncProjection and AsyncProjectionCheckpointStore.

Implementations provide input identity, duplicate detection, read-model updates, and any atomic checkpoint persistence. The trait itself implements no deduplication. The projection must be Send, its event Sync, its cursor Send + Sync, and its error Send for the boxed Send future. The projection need not be Sync; mutable borrowing prevents overlapping calls on the same value.

Dropping a future stops polling but does not establish whether changes occurred or were rolled back, even before the first poll: implementations may act during the method call. Adapters must document cancellation, retry, partial-update, and panic behavior at their persistence boundary.

日本語:
crate::AsyncProjection と AsyncProjectionCheckpointStore から独立した、 重複を区別する非同期プロジェクションです。

入力の識別、重複検出、読み取りモデル更新、原子的なチェックポイント永続化は実装が提供します。 トレイト自体は重複排除を実装しません。ボックス化された Send Future のため、 プロジェクションには Send、イベントには Sync、カーソルには Send + Sync、エラーには Send が必要です。 プロジェクション自体に Sync は不要です。同じ値への呼び出しの重複は可変借用が防ぎます。

Future の破棄はポーリングを止めますが、変更の有無やロールバックを保証しません。 メソッド呼び出し中にも処理できるため、初回ポーリング前でも同様です。永続化境界における キャンセル、再試行、部分更新、パニックの挙動はアダプターが文書化する必要があります。

Required Associated Types§

Source

type Event: DomainEvent + Sync

English:
Domain event shareable through its borrowed reference in a Send future.

日本語:
Send Future 内の借用参照を通して共有できるドメインイベントです。

Source

type Cursor: Send + Sync

English:
Progress representation used to associate the borrowed checkpoint with input.

日本語:
借用したチェックポイントを入力に関連付ける進捗表現です。

Source

type Error: Send

English:
Transferable failure from duplicate detection or read-model application.

日本語:
重複検出や読み取りモデルへの適用で生じる、移動可能な失敗です。

Required Methods§

Source

fn apply_once<'a>( &'a mut self, event: &'a Self::Event, checkpoint: &'a ProjectionCheckpoint<Self::Cursor>, ) -> Pin<Box<dyn Future<Output = Result<ProjectionApplication, Self::Error>> + Send + 'a>>

English:
Borrows the projection exclusively and the event and checkpoint jointly for 'a. The future reports ProjectionApplication::Applied, ProjectionApplication::AlreadyApplied, or an error that does not rule out partial updates. It does not automatically call a checkpoint store. Checkpoint interpretation and whether progress is persisted belong to the implementation.

日本語:
プロジェクションを排他的に、イベントとチェックポイントを共有で、いずれも 'a の間借用します。 Future は ProjectionApplication::Applied、ProjectionApplication::AlreadyApplied、 または部分更新の可能性を排除しないエラーを返します。チェックポイントストアは自動では呼び出しません。 チェックポイントの解釈と進捗を永続化するかどうかは実装が定めます。

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§