[−][src]Crate eventually_postgres
eventually
type implementations for PostgreSQL.
Event Store
This crate includes an EventStore
implementation using PostgreSQL
as backend data source.
Example usage:
// Open a connection with Postgres. let (client, connection) = tokio_postgres::connect("postgres://user@pass:localhost:5432/db", tokio_postgres::NoTls) .await .map_err(|err| { eprintln!("failed to connect to Postgres: {}", err); err })?; // The connection, responsible for the actual IO, must be handled by a different // execution context. tokio::spawn(async move { if let Err(e) = connection.await { eprintln!("connection error: {}", e); } }); // A domain event example -- it is deliberately simple. #[derive(Debug, Clone)] struct SomeEvent; // Use an EventStoreBuilder to build multiple EventStore instances. let builder = EventStoreBuilder::from(Arc::new(RwLock::new(client))); // Events should be versioned to be used with the Postgres Event Store. use eventually::versioned::Versioned; // Event store for the events. let store = { let store = builder.event_stream::<String, Versioned<SomeEvent>>("orders"); store.create_stream().await?; store };
Structs
EventStore |
|
EventStoreBuilder | Builder type for |