Skip to content

Commit

Permalink
docs and is_some
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo-rendina-prima committed May 7, 2024
1 parent fb1ff8e commit 3a6c96e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version = "0.15.0"
all-features = true

[features]
default = []
default = ["postgres", "rebuilder", "kafka", "rabbit", "upcasting"]
postgres = ["sqlx", "sqlx/postgres", "typed-builder", "tokio"]
rebuilder = []
kafka = ["rdkafka", "typed-builder"]
Expand Down
1 change: 1 addition & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ where
pub trait TransactionalEventHandler<A, Er, Ex>: Sync
where
A: Aggregate,
Ex: Send,
{
/// Handle an event in a transactional fashion and perform a read side crate, update or delete.
/// If an error is returned the transaction will be aborted and the handling of a command by an
Expand Down
3 changes: 1 addition & 2 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ where
/// Acquires a lock on this aggregate instance, and only then loads it from the event store,
/// by applying previously persisted events onto the aggregate state by order of their sequence number.
///
/// The lock is contained in the returned `AggregateState`, and released when this is dropped.
/// It can also be extracted with the `take_lock` method for more advanced uses.
/// The returned `LockedLoad` contains the outcome of the load and is responsible for correctly managing the lock.
pub async fn lock_and_load(
&self,
aggregate_id: impl Into<Uuid> + Send,
Expand Down
9 changes: 9 additions & 0 deletions src/manager/locked_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ impl<T> LockedLoad<T> {
Self(LockedLoadInner::None { id, lock })
}

/// Checks if the AggregateState was found.
pub fn is_some(&self) -> bool {
let Self(inner) = self;
match inner {
LockedLoadInner::None { .. } => false,
LockedLoadInner::Some(_) => true,
}
}

/// Extracts the contained AggregateState, or panics otherwise.
pub fn unwrap(self) -> AggregateState<T> {
let Self(inner) = self;
Expand Down

0 comments on commit 3a6c96e

Please sign in to comment.