[−][src]Struct eventually_postgres::EventStoreBuilder
Builder type for EventStore
instances.
Implementations
impl EventStoreBuilder
[src]
pub fn event_stream<Id, Event>(
&self,
name: &'static str
) -> EventStore<Id, Event>
[src]
&self,
name: &'static str
) -> EventStore<Id, Event>
Creates a new EventStore
instance using the specified stream name
as the Postgres backend table.
pub fn aggregate_stream<T>(
&self,
_: &T,
name: &'static str
) -> EventStore<AggregateId<T>, T::Event> where
T: Aggregate,
[src]
&self,
_: &T,
name: &'static str
) -> EventStore<AggregateId<T>, T::Event> where
T: Aggregate,
Creates a new EventStore
for an Aggregate
type,
backed by a Postgres table using the specified stream name.
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);
}
});
// Use an EventStoreBuilder to build multiple EventStore instances.
let builder = EventStoreBuilder::from(Arc::new(RwLock::new(client)));
// Aggregates should be versioned to be used with the Postgres Event Store.
use eventually_util::versioned::AggregateExt;
let aggregate = SomeAggregate.versioned();
// Event store for the events.
let store = {
let store = builder.aggregate_stream(&aggregate, "orders");
store.create_stream().await?;
store
};
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for EventStoreBuilder
impl Send for EventStoreBuilder
impl Sync for EventStoreBuilder
impl Unpin for EventStoreBuilder
impl !UnwindSafe for EventStoreBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,