eventium-memory: In-memory implementations for eventium

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Eventium-memory provides in-memory implementations of event stores, read models, and projection caches for the Eventium event sourcing framework. This package is ideal for development, testing, and prototyping event-sourced applications without requiring external dependencies like databases. All data is stored in STM-based concurrent data structures for thread-safe access.


[Skip to Readme]

Properties

Versions 0.1.0, 0.1.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), containers (>=0.6 && <0.8), eventium-core (>=0.1.0 && <0.2.0), mtl (>=2.2 && <2.4), safe (>=0.3 && <0.4), stm (>=2.5 && <2.6) [details]
License MIT
Author
Maintainer Alexander Sidorenko
Category Database, Eventsourcing
Home page https://github.com/aleks-sidorenko/eventium#readme
Bug tracker https://github.com/aleks-sidorenko/eventium/issues
Source repo head: git clone https://github.com/aleks-sidorenko/eventium
Uploaded by aleks_sidorenko at 2025-12-12T21:56:25Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for eventium-memory-0.1.0

[back to package description]

Eventium Memory

In-memory implementations of event stores, read models, and projection caches for Eventium.

Overview

eventium-memory provides thread-safe, in-memory storage implementations for the Eventium event sourcing framework. This package is ideal for development, testing, and prototyping event-sourced applications without requiring external dependencies like databases.

Features

Components

Event Store (Eventium.Store.Memory)

Implements both EventStoreReader and EventStoreWriter with:

Read Model (Eventium.ReadModel.Memory)

In-memory read model implementation for building query-optimized views.

Projection Cache (Eventium.ProjectionCache.Memory)

Stores projection snapshots in memory to avoid replaying entire event histories.

Usage

import Eventium.Store.Memory (newEventStore)
import Control.Concurrent.STM (atomically)

main :: IO ()
main = do
  -- Create a new in-memory event store
  store <- atomically newEventStore
  
  -- Use it with your command handlers and projections
  result <- applyCommandHandler 
    (eventStoreWriter store)
    (eventStoreReader store) 
    myCommandHandler 
    aggregateId 
    command

Installation

Add to your package.yaml:

dependencies:
  - eventium-core
  - eventium-memory

Or to your .cabal file:

build-depends:
    eventium-core
  , eventium-memory

Use Cases

Development

Quickly prototype event-sourced applications without database setup.

Testing

Demonstration

Perfect for demos, tutorials, and learning event sourcing concepts.

Example

-- Create store
store <- atomically newEventStore

-- Write events
writeResult <- atomically $ 
  writeEvents (eventStoreWriter store) 
    streamKey 
    ExpectedPositionAny 
    [event1, event2]

-- Read events back
events <- atomically $ 
  readEvents (eventStoreReader store) 
    streamKey 
    QueryRangeAll

Limitations

For production use, consider:

Documentation

License

MIT - see LICENSE.md