eventsourcing/memory_store
Types
pub type EventMessage(event) {
SetEvents(
key: String,
value: List(eventsourcing.EventEnvelop(event)),
)
GetEvents(
key: String,
response: process.Subject(
option.Option(List(eventsourcing.EventEnvelop(event))),
),
)
}
Constructors
-
SetEvents( key: String, value: List(eventsourcing.EventEnvelop(event)), )
-
GetEvents( key: String, response: process.Subject( option.Option(List(eventsourcing.EventEnvelop(event))), ), )
In-memory event store implementation for development and testing. This store persists events and snapshots in memory using supervised actors. Data is lost when the application restarts.
pub opaque type MemoryStore(entity, command, event, error)
pub type SnapshotMessage(entity) {
SetSnapshot(key: String, value: eventsourcing.Snapshot(entity))
GetSnapshot(
key: String,
response: process.Subject(
option.Option(eventsourcing.Snapshot(entity)),
),
)
}
Constructors
-
SetSnapshot(key: String, value: eventsourcing.Snapshot(entity))
-
GetSnapshot( key: String, response: process.Subject( option.Option(eventsourcing.Snapshot(entity)), ), )
Values
pub fn supervised(
events_actor_name: process.Name(EventMessage(event)),
snapshot_actor_name: process.Name(SnapshotMessage(entity)),
strategy: static_supervisor.Strategy,
) -> #(
eventsourcing.EventStore(
MemoryStore(entity, command, event, error),
entity,
command,
event,
error,
MemoryStore(entity, command, event, error),
),
supervision.ChildSpecification(static_supervisor.Supervisor),
)
Creates a supervised in-memory event store with separate actors for events and snapshots. Returns both the EventStore interface and a supervision specification that manages the underlying storage actors.
Example
let events_name = process.new_name("events_actor")
let snapshot_name = process.new_name("snapshot_actor")
let #(eventstore, supervisor_spec) = memory_store.supervised(
events_name,
snapshot_name,
static_supervisor.OneForOne
)