EventStore

zio.blocks.projection.EventStore
trait EventStore[E]

An append-only log of the events of one event type E.

Each appended event gets the next sequence number, which also gives the order of the events. The store streams the events it holds from any position, and publishes every new event to a Hub, so that a reader can catch up on the history and then follow the new events. A ProjectionEngine reads each source of a projection from one event store.

SQLiteEventStore keeps the events in a SQLite file.

Type parameters

E

the event type, usually a sealed trait with one case for each kind of event

Attributes

Source
EventStore.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class SQLiteEventStore[E]

Members list

Value members

Abstract methods

def append(entityId: String, event: E): Task[Long]

Appends event, recorded under the entity entityId, and returns its sequence number.

Appends event, recorded under the entity entityId, and returns its sequence number.

The event is stored first, and its EventEnvelope is then published to the hub returned by subscribe.

Value parameters

entityId

the entity the event belongs to, which a handler sees as ProjectionContext#entityId

event

the event to store

Attributes

Returns

the sequence number given to the event, greater than that of every event stored before it

Source
EventStore.scala
def readAll(tags: Set[String] = ...): ZStream[Any, Throwable, EventEnvelope[E]]

Streams every stored event, in order. The same as readFrom(0L, tags).

Streams every stored event, in order. The same as readFrom(0L, tags).

A schema rebuild uses it to replay all the events.

Value parameters

tags

the tags of the events to keep; the empty set, the default, keeps them all

Attributes

Source
EventStore.scala
def readFrom(afterSeq: Long, tags: Set[String] = ...): ZStream[Any, Throwable, EventEnvelope[E]]

Streams the stored events whose sequence number is greater than afterSeq, in order.

Streams the stored events whose sequence number is greater than afterSeq, in order.

The engine uses it to catch up from the last event it processed.

Value parameters

afterSeq

the sequence number to read after; 0 reads from the first event

tags

the tags of the events to keep; the empty set, the default, keeps them all

Attributes

Source
EventStore.scala
def subscribe: Hub[EventEnvelope[E]]

The hub that every appended event is published to.

The hub that every appended event is published to.

Despite its name, this does not subscribe. Call subscribe on the returned hub, inside a Scope, to receive the events appended from then on. The events stored before that are read with readFrom.

Attributes

Source
EventStore.scala