Sourcing::Plugin
The Sourcing library uses two plugin roles to handle different aspects of event sourcing:
Plugin Roles
Sourcing provides two plugin roles for different storage concerns:
Sourcing::Plugin::EventStore
Handles event storage operations:
- emit — persisting events to storage
- get-events — fetching events by ID criteria
- get-events-after — fetching events after a version for catch-up
- supply — streaming events in real-time
Sourcing::Plugin::StateCache
Handles projection state caching:
- store-cached-data — caching projection state
- get-cached-data — retrieving cached state for fast recovery
Architecture
This separation enables flexible architectures:
- Different backends — Use PostgreSQL for events but Redis for state cache
- Independent scaling — Scale event store and cache separately
- Hybrid approaches — Mix memory and persistent storage as needed
Combined Implementation
For convenience, Sourcing::Plugin::Memory implements both roles in a single class. This is useful for testing and development.
See Also
- Sourcing::Plugin::EventStore — event storage interface
- Sourcing::Plugin::StateCache — state caching interface
- Sourcing::Plugin::Memory — combined implementation
- Writing a Plugin Guide — how to implement your own plugin