-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LockedLoad #194
LockedLoad #194
Conversation
/// It's essentially `Option<AggregateState<T>>`, but it also needs to | ||
/// retain the lock information. | ||
enum LockedLoadInner<T> { | ||
None { id: Uuid, lock: EventStoreLockGuard }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do this need to have an id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the use case is:
- you do lock_and_load(ID)
- you get Empty { ID, ... }
- you do .unwrap_or_default which gives you
AggregateState<T>::default().with_id(ID).with_lock(lock)
TLDR: LockedLoad is the result of trying lock_and_load on a specific ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there can be a scenario where you do
result = lock_and_load(123)
if result is None
result = AggregateState::new() // <-- completely new ID, say 456
so we likely want LockedLoad::is_none
, LockedLoad::is_some
, LockedLoad::unwrap_or
, LockedLoad::unwrap_or_else
utilites to support this use case!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense
/// It's essentially `Option<AggregateState<T>>`, but it also needs to | ||
/// retain the lock information. | ||
enum LockedLoadInner<T> { | ||
None { id: Uuid, lock: EventStoreLockGuard }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only small suggestion about constructors visibility. I don't think user should be able to create a new instance of this struct
3a6c96e
to
5595129
Compare
5595129
to
8ab3e7b
Compare
No description provided.