Skip to content
docsv0.1.0

EventStoreInterface

An append-only log of {@see Event}s, partitioned into independently replayable streams. A stream's state is never stored — it is always reconstructed by replaying its events in order, so an implementation's only jobs are "append durably" and "read back in order".

EventStoreInterface::append()

abstract public function append(Milpa\EventStore\Event $event): void

Appends `$event` to the store. Events are never mutated or removed once appended.

Parameters

Parameters of append()
NameTypeDescription
$eventMilpa\EventStore\Event

EventStoreInterface::replay()

abstract public function replay(string $streamId): array

All events belonging to `$streamId`, in ascending `seq` order. Events belonging to other streams never appear in the result.

Parameters

Parameters of replay()
NameTypeDescription
$streamIdstring

EventStoreInterface::nextSeq()

abstract public function nextSeq(): int

The next `seq` to assign, one past the highest `seq` currently in the store across every stream — `1` for an empty store. The sequence is a single monotonic counter shared by the whole store, not per stream.

EventStoreInterface::streams()

abstract public function streams(): array

Every distinct stream id present in the store, in the order each first appears (ascending `seq` of its first event) — `[]` for an empty store. For read-side scans across ALL streams (e.g. discovering every process instance a consumer has ever started) that cannot start from a single, already-known stream id the way {@see self::replay()} does.