Sourcing::Plugin::EventStore

Abstract role defining the interface for event storage backends. Event stores handle event persistence, retrieval, and the supply of events for projections.

Overview

The EventStore role handles all event-related operations:

See also: Sourcing::Plugin::StateCache for the state caching interface.

Abstract Methods

method emit($event, :$current-version)

Emits an event to the storage backend. Implementations should handle persistence and broadcast on the event supply.

ParameterTypeDescription
$eventAnyThe event to emit
:$current-versionIntExpected version for optimistic locking (optional)

method get-events(%ids, %map)

Retrieves all events matching the given identity criteria and event type map.

ParameterTypeDescription
%idsHashHash of identity attribute names to values
%mapHashHash mapping event types to their identity mappings

method get-events-after($id, %ids, %map)

Retrieves events that occurred after the specified version ID. Used for projection catch-up.

ParameterTypeDescription
$idIntThe version/ID to get events after
%idsHashIdentity filtering criteria
%mapHashEvent type mapping

method supply

Returns a Supply of events from this storage backend. Emits events as they are stored.

Returns: A Supply that emits events in real-time.

Class Methods

method use(|c)

Activates this plugin as the current sourcing configuration by setting PROCESS::<$SourcingConfig>.

Sourcing::Plugin::EventStore::Memory.use;

Dynamic Variables

VariableDescription
$*SourcingConfigThe active plugin instance, set by Plugin.use
$*SourcingReplayWhen truthy, suppresses event emission from auto-generated methods. Set to True when replaying events to prevent double-emission.

See Also