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:
- Event emission — persisting events to storage
- Event retrieval — fetching events by ID or version
- Event streaming — providing a Supply for real-time event delivery
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.
| Parameter | Type | Description |
|---|---|---|
$event | Any | The event to emit |
:$current-version | Int | Expected version for optimistic locking (optional) |
method get-events(%ids, %map)
Retrieves all events matching the given identity criteria and event type map.
| Parameter | Type | Description |
|---|---|---|
%ids | Hash | Hash of identity attribute names to values |
%map | Hash | Hash 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.
| Parameter | Type | Description |
|---|---|---|
$id | Int | The version/ID to get events after |
%ids | Hash | Identity filtering criteria |
%map | Hash | Event 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
| Variable | Description |
|---|---|
$*SourcingConfig | The active plugin instance, set by Plugin.use |
$*SourcingReplay | When truthy, suppresses event emission from auto-generated methods. Set to True when replaying events to prevent double-emission. |
See Also
- Sourcing::Plugin::EventStore::Memory — the built-in in-memory implementation
- Sourcing::Plugin::StateCache — the state caching interface
- Sourcing::Plugin::Memory — combined implementation
- Writing a Plugin Guide — how to implement your own plugin