pub struct PostgresEventStore { /* private fields */ }Expand description
PostgreSQL-backed event store implementing EventCore’s storage traits.
Provides atomic multi-stream event writes with optimistic concurrency control, advisory locks for projector coordination, and connection pooling.
Use PostgresEventStore::new (or PostgresEventStore::with_config) with a
PostgreSQL connection URL to create an instance.
Implementations§
Source§impl PostgresEventStore
impl PostgresEventStore
Sourcepub async fn new<S: Into<String>>(
connection_string: S,
) -> Result<Self, PostgresEventStoreError>
pub async fn new<S: Into<String>>( connection_string: S, ) -> Result<Self, PostgresEventStoreError>
Create a new PostgresEventStore with default configuration.
Sourcepub async fn with_config<S: Into<String>>(
connection_string: S,
config: PostgresConfig,
) -> Result<Self, PostgresEventStoreError>
pub async fn with_config<S: Into<String>>( connection_string: S, config: PostgresConfig, ) -> Result<Self, PostgresEventStoreError>
Create a new PostgresEventStore with custom configuration.
Sourcepub fn from_pool(pool: Pool<Postgres>) -> Self
pub fn from_pool(pool: Pool<Postgres>) -> Self
Create a PostgresEventStore from an existing connection pool.
Use this when you need full control over pool configuration or want to share a pool across multiple components.
Sourcepub async fn ping(&self)
pub async fn ping(&self)
Verify connectivity by issuing a trivial SELECT 1 query.
§Panics
Panics if the database is unreachable or the query fails.
Sourcepub async fn migrate(&self)
pub async fn migrate(&self)
Apply the bundled schema migrations via sqlx::migrate!("./migrations").
This creates the tables EventCore requires, including the
eventcore_subscription_versions table used by PostgresCheckpointStore.
§Panics
Panics if applying the migrations fails.
Trait Implementations§
Source§impl CheckpointStore for PostgresEventStore
impl CheckpointStore for PostgresEventStore
Source§impl Clone for PostgresEventStore
impl Clone for PostgresEventStore
Source§fn clone(&self) -> PostgresEventStore
fn clone(&self) -> PostgresEventStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PostgresEventStore
impl Debug for PostgresEventStore
Source§impl EventReader for PostgresEventStore
impl EventReader for PostgresEventStore
Source§type Error = EventStoreError
type Error = EventStoreError
Source§async fn read_events<E: Event>(
&self,
filter: EventFilter,
page: EventPage,
) -> Result<Vec<(E, StreamPosition)>, Self::Error>
async fn read_events<E: Event>( &self, filter: EventFilter, page: EventPage, ) -> Result<Vec<(E, StreamPosition)>, Self::Error>
Source§impl EventStore for PostgresEventStore
impl EventStore for PostgresEventStore
Source§async fn read_stream<E: Event>(
&self,
stream_id: StreamId,
) -> Result<EventStream<E>, EventStoreError>
async fn read_stream<E: Event>( &self, stream_id: StreamId, ) -> Result<EventStream<E>, EventStoreError>
Source§async fn append_events(
&self,
writes: StreamWrites,
) -> Result<EventStreamSlice, EventStoreError>
async fn append_events( &self, writes: StreamWrites, ) -> Result<EventStreamSlice, EventStoreError>
Source§impl ProjectorCoordinator for PostgresEventStore
impl ProjectorCoordinator for PostgresEventStore
Source§type Error = CoordinationError
type Error = CoordinationError
Source§type Guard = CoordinationGuard
type Guard = CoordinationGuard
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
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>
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>
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