arc-es-postgres 0.2.3

Postgres EventStore and ReadModelStore implementation for arc event sourcing
Documentation

arc-es-postgres

Postgres storage adapters for Arc event sourcing.

This crate implements Arc's EventStore, ReadModelStore, and snapshot persistence on Postgres. It is intended for production deployments and multi-process Arc applications.

What It Provides

  • PostgresEventStore: append-only event store with optimistic concurrency.
  • PostgresReadModelStore: JSONB read-model storage for projections.
  • Self-initializing schema helpers for events, snapshots, and read models.
  • Optional HMAC integrity-chain enforcement for persisted events.

Example

use arc_core::audit::AuditMetadata;
use arc_core::event::Event;
use arc_core::event_store::{EventStore, VersionCheck};
use arc_es_postgres::PostgresEventStore;
use serde_json::json;

# async fn example() -> Result<(), Box<dyn std::error::Error>> {
let store = PostgresEventStore::new("postgres://arc:password@localhost:5432/arc").await?;
store.initialize_schema().await?;

let event = Event::new(
    "User",
    "user-123",
    1,
    "UserRegistered",
    json!({ "email": "ada@example.test" }),
)
.with_audit(AuditMetadata::system());

store
    .append("user-123", VersionCheck::New, vec![event])
    .await?;
# Ok(())
# }

Integrity Mode

Use PostgresEventStore::new_with_integrity_key or PostgresEventStore::with_pool_and_integrity_key to sign new events and verify events on load/stream. Existing unsigned data must be replayed or migrated before enabling integrity verification.

Stability

This crate is pre-1.0 and follows arc-core's compatibility line. Breaking changes may ship in minor versions until 1.0.

License

MIT