AshCommanded.Commanded.SnapshotAdapter (AshCommanded v0.1.0)
View SourceAdapter to integrate AshCommanded's snapshot functionality with Commanded.
This module implements the necessary callbacks to allow Commanded to use AshCommanded's snapshot functionality during aggregate initialization and event application.
It implements the Commanded.Aggregates.Aggregate.Snapshotter
behaviour
to integrate with Commanded's built-in snapshot support when it's available.
During tests without Commanded, it falls back to simpler implementation.
Summary
Functions
Loads a snapshot for an aggregate.
Returns the snapshot threshold for an aggregate module.
Returns the snapshot schema version for an aggregate module.
Takes a snapshot of an aggregate's state.
Functions
Loads a snapshot for an aggregate.
Parameters
aggregate_module
- The aggregate moduleaggregate_uuid
- The unique identifier of the aggregate
Returns
{:ok, version, state}
- If a snapshot was found{:error, reason}
- If no snapshot was found or could not be loaded
Returns the snapshot threshold for an aggregate module.
Parameters
aggregate_module
- The aggregate module
Returns
The number of events to process before taking a snapshot, or nil if snapshotting is disabled
Returns the snapshot schema version for an aggregate module.
Parameters
aggregate_module
- The aggregate module
Returns
The snapshot schema version
Takes a snapshot of an aggregate's state.
Parameters
aggregate_module
- The aggregate moduleaggregate_state
- The current state of the aggregate
Returns
{:ok, snapshot}
- If the snapshot was taken successfully{:error, reason}
- If the snapshot could not be taken