Skip to main content

AggregateReplay

Trait AggregateReplay 

Source
pub trait AggregateReplay: AggregateRoot {
    type InitializationError;
    type ApplicationError;
    type Snapshot;
    type SnapshotValidationError;
    type SnapshotStateError;

    // Required methods
    fn initial_state(id: &Self::Id) -> Result<Self, Self::InitializationError>
       where Self: Sized;
    fn apply_event(
        &mut self,
        event: &Self::Event,
    ) -> Result<(), Self::ApplicationError>;
    fn classify_snapshot(
        snapshot: &AggregateSnapshot<Self::Snapshot>,
        stream_revision: StreamRevision,
    ) -> Result<SnapshotUse, Self::SnapshotValidationError>;
    fn from_snapshot(
        id: &Self::Id,
        snapshot: AggregateSnapshot<Self::Snapshot>,
    ) -> Result<Self, Self::SnapshotStateError>
       where Self: Sized;
}
Expand description

English:
Aggregate hooks for reconstructing state from stored events or a snapshot. Implementations should apply historical events without recording new pending events. The replay helpers do not clear queues, check aggregate identity, publish events, or catch panics from these hooks. Error and panic conditions are defined by each implementation.

日本語:
保存イベントまたはスナップショットから状態を復元するための集約フックです。 実装では履歴イベントの適用で新たな保留イベントを記録しないようにします。 再生ヘルパーはキューの消去、集約識別子の確認、イベント発行、フックのパニック捕捉をしません。 エラーとパニックの条件は各実装が定めます。

Required Associated Types§

Source

type InitializationError

English:
Failure to create the pre-event state.

日本語:
イベント適用前の状態の作成失敗です。

Source

type ApplicationError

English:
Failure to apply a historical event.

日本語:
履歴イベントの適用失敗です。

Source

type Snapshot

English:
State representation consumed when restoring a snapshot.

日本語:
スナップショット復元時に消費する状態表現です。

Source

type SnapshotValidationError

English:
Failure to classify a snapshot, distinct from choosing full replay.

日本語:
スナップショット分類の失敗です。全件再生を選ぶこととは区別されます。

Source

type SnapshotStateError

English:
Failure to construct aggregate state from an accepted snapshot.

日本語:
採用したスナップショットからの集約状態構築失敗です。

Required Methods§

Source

fn initial_state(id: &Self::Id) -> Result<Self, Self::InitializationError>
where Self: Sized,

English:
Creates state for id before any historical events are applied. Returns an implementation-defined error if initialization fails.

日本語:
履歴イベント適用前の id の状態を作成します。 初期化に失敗した場合は実装定義のエラーを返します。

Source

fn apply_event( &mut self, event: &Self::Event, ) -> Result<(), Self::ApplicationError>

English:
Updates state using one borrowed historical event, without emitting it again. Returns an implementation-defined error on failure; mutations before that error are not undone.

日本語:
借用した履歴イベント 1 件で状態を更新し、そのイベントを再発行しません。 失敗時は実装定義のエラーを返します。それ以前の状態変更は元に戻されません。

Source

fn classify_snapshot( snapshot: &AggregateSnapshot<Self::Snapshot>, stream_revision: StreamRevision, ) -> Result<SnapshotUse, Self::SnapshotValidationError>

English:
Classifies snapshot against the complete history’s stream_revision. Return SnapshotUse::Applicable to restore it, or another classification to replay all events. An error aborts replay rather than falling back. Compatibility and staleness policy belong here.

日本語:
完全な履歴の stream_revision に照らして snapshot を分類します。 復元するなら SnapshotUse::Applicable、全件再生するなら他の分類を返します。 エラー時はフォールバックせず再生を中断します。互換性と古さの方針をここで定めます。

Source

fn from_snapshot( id: &Self::Id, snapshot: AggregateSnapshot<Self::Snapshot>, ) -> Result<Self, Self::SnapshotStateError>
where Self: Sized,

English:
Consumes an accepted snapshot to construct the aggregate for id. Returns an implementation-defined state error; replay does not retry from the initial state.

日本語:
採用済みスナップショットを消費し、id の集約を構築します。 失敗時は実装定義の状態エラーを返し、初期状態からの再試行は行いません。

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§