pub struct PostgresEventStore { /* private fields */ }Expand description
Postgres implementation of EventStore.
Implementations§
Source§impl PostgresEventStore
impl PostgresEventStore
Sourcepub async fn new(database_url: &str) -> EventStoreResult<Self>
pub async fn new(database_url: &str) -> EventStoreResult<Self>
Build a store from a Postgres connection URL, creating a small pool.
Sourcepub async fn new_with_integrity_key(
database_url: &str,
key: impl Into<Vec<u8>>,
key_id: impl Into<String>,
) -> EventStoreResult<Self>
pub async fn new_with_integrity_key( database_url: &str, key: impl Into<Vec<u8>>, key_id: impl Into<String>, ) -> EventStoreResult<Self>
Build a store from a Postgres connection URL with an integrity key.
Sourcepub fn with_pool(pool: PgPool) -> Self
pub fn with_pool(pool: PgPool) -> Self
Build a store from an existing pool. Lets tests share one pool with the read-model store against the same database.
Sourcepub fn with_pool_and_integrity_key(
pool: PgPool,
key: impl Into<Vec<u8>>,
key_id: impl Into<String>,
) -> EventStoreResult<Self>
pub fn with_pool_and_integrity_key( pool: PgPool, key: impl Into<Vec<u8>>, key_id: impl Into<String>, ) -> EventStoreResult<Self>
Build a store from an existing pool and an integrity key.
Sourcepub fn pool(&self) -> &PgPool
pub fn pool(&self) -> &PgPool
Borrow the underlying pool (e.g. to construct a read-model store that shares the same connections).
Sourcepub async fn initialize_schema(&self) -> EventStoreResult<()>
pub async fn initialize_schema(&self) -> EventStoreResult<()>
Create the events and snapshots tables and their indexes if absent.
Idempotent; safe to call on every startup.
Trait Implementations§
Source§impl Clone for PostgresEventStore
impl Clone for PostgresEventStore
Source§fn clone(&self) -> PostgresEventStore
fn clone(&self) -> PostgresEventStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl EventStore for PostgresEventStore
impl EventStore for PostgresEventStore
Source§fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
version_check: VersionCheck,
new_events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
version_check: VersionCheck,
new_events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Append events to the store for a specific aggregate. Read more
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_from<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
from_sequence: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream_all<'life0, 'async_trait>(
&'life0 self,
from_position: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_version<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn save_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
snapshot: &'life1 Snapshot,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
snapshot: &'life1 Snapshot,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persist an aggregate snapshot (upsert by
aggregate_id). Read moreSource§fn load_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the latest snapshot for an aggregate, if one exists. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresEventStore
impl !UnwindSafe for PostgresEventStore
impl Freeze for PostgresEventStore
impl Send for PostgresEventStore
impl Sync for PostgresEventStore
impl Unpin for PostgresEventStore
impl UnsafeUnpin for PostgresEventStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more