Nexus API Reference

TracingEventStore
in package
implements EventStore

FinalYes
Tags
psalm-api

Tracing decorator for an EventStore. Adds an Internal span and metrics per operation. Store errors propagate (recorded on the span first); telemetry errors never break the operation. Delegates directly when observability is disabled.

Table of Contents

Interfaces

EventStore
Read/write interface for event-sourced event streams.

Methods

__construct()  : mixed
deleteUpTo()  : void
Delete all events up to and including `$toSequenceNr` for the given actor.
highestSequenceNr()  : int
Return the highest sequence number written for `$id`, or 0 if no events exist.
load()  : iterable<string|int, EventEnvelope>
Load events for `$id` within the given sequence number range (inclusive).
persist()  : void
Append one or more events to the stream identified by `$id`.

Methods

deleteUpTo()

Delete all events up to and including `$toSequenceNr` for the given actor.

public deleteUpTo(PersistenceId $id, int $toSequenceNr) : void

Called by the retention policy after a snapshot is confirmed durable. Implementations should be idempotent — deleting already-deleted events is a no-op.

Parameters
$id : PersistenceId
$toSequenceNr : int

highestSequenceNr()

Return the highest sequence number written for `$id`, or 0 if no events exist.

public highestSequenceNr(PersistenceId $id) : int

Used by the engine to detect writer conflicts and to set the starting point for the next persist() call.

Parameters
$id : PersistenceId
Return values
int

load()

Load events for `$id` within the given sequence number range (inclusive).

public load(PersistenceId $id[, int $fromSequenceNr = 0 ][, int $toSequenceNr = PHP_INT_MAX ]) : iterable<string|int, EventEnvelope>

Defaults to the full stream. The PersistenceEngine passes $fromSequenceNr as one past the last snapshot sequence number to avoid replaying already-applied events.

Parameters
$id : PersistenceId
$fromSequenceNr : int = 0
$toSequenceNr : int = PHP_INT_MAX
Return values
iterable<string|int, EventEnvelope>

persist()

Append one or more events to the stream identified by `$id`.

public persist(PersistenceId $id, EventEnvelope ...$events) : void

Implementations must write all events atomically and assign monotonically increasing sequence numbers. Throws on write failure.

Parameters
$id : PersistenceId
$events : EventEnvelope

        
On this page

Search results