gossip_event_sourcing library
Event Sourcing and CQRS library for Dart applications
This library provides the core components for implementing Event Sourcing and Command Query Responsibility Segregation (CQRS) patterns in distributed applications built on the Gossip protocol.
Key components:
- EventProcessor: Coordinates event processing to projections
- Projection: Base class for read models
- ProjectionStore: Interface for persistent projection state storage
Example usage:
// Create a custom projection store implementation
final projectionStore = MyProjectionStore();
await projectionStore.initialize();
// Create event processor
final eventProcessor = EventProcessor(
projectionStore: projectionStore,
storeConfig: const ProjectionStoreConfig(),
);
// Create and register your projections
final myProjection = MyProjection();
eventProcessor.registerProjection(myProjection);
// Process events
await eventProcessor.processEvent(event);
Classes
- EventProcessor
- Coordinates processing of events to update projections. This is the core of the Event Sourcing architecture.
- Projection
- Base class for all projections (read models). Projections build and maintain UI state from events.
- ProjectionStateMetadata
- Metadata about a saved projection state (without the actual state data)
- ProjectionStateSnapshot
- Represents a saved projection state with metadata
- ProjectionStore
- Interface for storing and loading projection states to avoid replaying all events This is an optional performance optimization for large event stores
- ProjectionStoreConfig
- Configuration for projection store behavior
- ProjectionStoreStats
- Statistics about the projection store
Mixins
- ProjectionChangeNotifier
- Simple change notifier mixin for projections that need to notify listeners This is framework-agnostic and doesn't depend on Flutter's ChangeNotifier
Exceptions / Errors
- ProjectionStoreException
- Exception thrown by projection store operations