Expand description
PostgreSQL event store backend for EventCore.
This crate provides a production-grade PostgresEventStore backed by PostgreSQL,
with ACID transactions, advisory locks, and connection pooling via sqlx.
Event immutability is enforced by PostgreSQL triggers. Stream pattern matching follows the conventions described in ADR-0047.
PostgresEventStore implements EventStore, EventReader, CheckpointStore,
and ProjectorCoordinator from eventcore-types. Its normal migration
creates the durable command-state snapshot table used by snapshot-enabled
commands.
The projections module adds a transactional read-model runner. It accepts
separate event-source and PostgreSQL destination pools, applies an event and
advances named progress in one destination transaction, and fences one
writer with a session advisory lock. Its exactly-once claim is limited to
acknowledged effect-plus-progress commits in that read-model database; it
does not cover the event store or external side effects. See the crate
README and projections::run_transactional_projection for setup and
recovery guidance. The pre-existing eventcore::Projector API is unchanged.
§Getting Started
use eventcore_postgres::PostgresEventStore;
let store = PostgresEventStore::new("postgres://user:pass@localhost/mydb").await?;Re-exports§
pub use projections::AfterCommit;pub use projections::BoxedProjectionError;pub use projections::NoopAfterCommit;pub use projections::PostgresProjectionConfig;pub use projections::PostgresProjectionMode;pub use projections::PostgresProjectionReset;pub use projections::PostgresProjectionSource;pub use projections::PostgresProjectionSourceError;pub use projections::PostgresProjectionStore;pub use projections::PostgresProjector;pub use projections::ProjectionConfigurationError;pub use projections::ProjectionFailureContext;pub use projections::ProjectionFailureDecision;pub use projections::ProjectionPollSleeper;pub use projections::ProjectionProgress;pub use projections::ProjectionResetAndReplayError;pub use projections::ProjectionResetError;pub use projections::ProjectionRetryPolicy;pub use projections::ProjectionRetrySleeper;pub use projections::ProjectionRunOutcome;pub use projections::TokioProjectionPollSleeper;pub use projections::TokioProjectionRetrySleeper;pub use projections::TransactionalProjectionError;pub use projections::reset_and_replay_transactional_projection;pub use projections::reset_transactional_projection;pub use projections::run_transactional_projection;
Modules§
- projections
- Transactional projection delivery support for PostgreSQL.
Structs§
- Coordination
Guard - Guard type that releases leadership when dropped.
- MaxConnections
- Maximum number of database connections in the pool.
- Postgres
Checkpoint Store - Postgres-backed checkpoint store for tracking projection progress.
- Postgres
Config - Configuration for PostgresEventStore connection pool.
- Postgres
Event Store - PostgreSQL-backed event store implementing EventCore’s storage traits.
- Postgres
Projector Coordinator - Postgres-backed projector coordinator for distributed leadership.
Enums§
- Coordination
Error - Error type for projector coordination operations.
- Postgres
Checkpoint Error - Error type for PostgresCheckpointStore operations.
- Postgres
Event Store Error - Errors that can occur when creating a
PostgresEventStore.