eventsourcing_inmemory
✨ In-Memory Event Store Implementation for Eventsourcing ✨
Introduction
eventsourcing_inmemory
provides an in-memory event store implementation for the eventsourcing library.
It’s designed for development, testing, and small-scale applications where persistence isn’t required.
Features
- In-Memory Storage: Fast, non-persistent event storage
- Snapshot Support: Built-in snapshot management for optimizing aggregate rebuilding
- Concurrent Access: Safe concurrent access to events and snapshots
- Error Handling: Comprehensive error handling with timeouts and process monitoring
- Zero Configuration: Ready to use with minimal setup
Installation
Add to your Gleam project:
gleam add eventsourcing_inmemory
Usage
Basic Setup
import eventsourcing
import eventsourcing_inmemory
pub fn main() {
// Create a new in-memory event store
let store = eventsourcing_inmemory.new()
// Create an event sourcing instance with the store
let event_sourcing = eventsourcing.new(
event_store: store,
queries: [],
handle: your_command_handler,
apply: your_event_applier,
empty_state: your_empty_state,
)
// Enable snapshots (optional)
|> with_snapshots(
event_sourcing,
eventsourcing.SnapshotConfig(100), // Snapshot every 100 events
)
}