eventsourcing_inmemory

In-Memory Event Store Implementation for Eventsourcing
Package Version Hex Docs

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

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
  )
}
Search Document