Skip to main content

nexus-persistence-dbal

Doctrine DBAL adapter for Nexus persistence — SQL-backed event store, snapshot store, and durable state store using parameterized queries.

What's in this package

Install

composer require nexus-actors/persistence-dbal

Quick example

src/Persistence/DbalSetup.php
use Doctrine\DBAL\DriverManager;
use Monadial\Nexus\Persistence\Dbal\DbalEventStore;
use Monadial\Nexus\Persistence\Dbal\DbalSnapshotStore;
use Monadial\Nexus\Persistence\Dbal\Schema\PersistenceSchemaManager;

$conn = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => 'nexus.db']);

(new PersistenceSchemaManager($conn))->createSchema();

$eventStore = new DbalEventStore($conn);
$snapshotStore = new DbalSnapshotStore($conn);

All three stores stamp each persisted envelope with the actor system's writer_id (ULID) for writer-conflict detection. Pass a custom MessageSerializer as the second constructor argument to override the default PhpNativeSerializer.

See also