pub trait DatabaseConnection: DatabaseProvider {
// Required methods
fn transact(
&self,
events: NonEmpty<ProspectiveEvent>,
conditions: Vec<AppendCondition>,
) -> impl Future<Output = Result<Self::AtRevision, DatabaseError>>;
fn transact_with_id(
&self,
transaction_id: &str,
events: NonEmpty<ProspectiveEvent>,
conditions: Vec<AppendCondition>,
) -> impl Future<Output = Result<Self::AtRevision, DatabaseError>>;
fn execute_state_change(
&self,
name: &StateChangeName,
version: u64,
request: CommandRequest,
) -> impl Future<Output = Result<Self::AtRevision, StateChangeError>>;
fn log(&self) -> impl Stream<Item = TransactionSummary>;
fn log_detail(&self) -> impl Stream<Item = Transaction>;
fn log_from(
&self,
from_revision: u64,
) -> impl Stream<Item = TransactionSummary>;
fn log_detail_from(
&self,
from_revision: u64,
) -> impl Stream<Item = Transaction>;
}Expand description
A database connection capable of performing transactions.
Required Methods§
Sourcefn transact(
&self,
events: NonEmpty<ProspectiveEvent>,
conditions: Vec<AppendCondition>,
) -> impl Future<Output = Result<Self::AtRevision, DatabaseError>>
fn transact( &self, events: NonEmpty<ProspectiveEvent>, conditions: Vec<AppendCondition>, ) -> impl Future<Output = Result<Self::AtRevision, DatabaseError>>
Transact events with append conditions.
The transaction must contain at least one event. Conditions are checked against the current database state before committing.
See: https://dcb.events/specification/ for the DCB append condition spec.
Sourcefn transact_with_id(
&self,
transaction_id: &str,
events: NonEmpty<ProspectiveEvent>,
conditions: Vec<AppendCondition>,
) -> impl Future<Output = Result<Self::AtRevision, DatabaseError>>
fn transact_with_id( &self, transaction_id: &str, events: NonEmpty<ProspectiveEvent>, conditions: Vec<AppendCondition>, ) -> impl Future<Output = Result<Self::AtRevision, DatabaseError>>
Transact events with a custom transaction ID.
This is useful for idempotency - if a transaction with the same ID has already been committed, the existing result is returned.
Sourcefn execute_state_change(
&self,
name: &StateChangeName,
version: u64,
request: CommandRequest,
) -> impl Future<Output = Result<Self::AtRevision, StateChangeError>>
fn execute_state_change( &self, name: &StateChangeName, version: u64, request: CommandRequest, ) -> impl Future<Output = Result<Self::AtRevision, StateChangeError>>
Execute a state change.
This invokes the named state change component with the given request and commits any resulting events.
Sourcefn log(&self) -> impl Stream<Item = TransactionSummary>
fn log(&self) -> impl Stream<Item = TransactionSummary>
Get the transaction log (summary only).
Sourcefn log_detail(&self) -> impl Stream<Item = Transaction>
fn log_detail(&self) -> impl Stream<Item = Transaction>
Get the transaction log with full event details.
Sourcefn log_from(&self, from_revision: u64) -> impl Stream<Item = TransactionSummary>
fn log_from(&self, from_revision: u64) -> impl Stream<Item = TransactionSummary>
Get the transaction log starting from a specific revision.
This returns transaction summaries for all transactions committed at or after the specified revision.
Sourcefn log_detail_from(&self, from_revision: u64) -> impl Stream<Item = Transaction>
fn log_detail_from(&self, from_revision: u64) -> impl Stream<Item = Transaction>
Get the transaction log with full event details, starting from a specific revision.
This returns full transaction details (including events) for all transactions committed at or after the specified revision.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.