-
Notifications
You must be signed in to change notification settings - Fork 239
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
Allow the aggregate's expected version to be included in command dispatch #482
Comments
I am not sure if this would be something that we should do. ScenarioGiven a The Having a $25 is not an invariant; such a limit was decision-making among the peers who owned the bucket. Reasons why I would like to redirect the attention to ConcernIf such a scenario does not reject the Command as soon as there is a mismatch, you could successfully fetch any missing events and retry the command, and then it will put the extra $5 in the bucket. As I said before, such a limit is not an invariant, so the consistent aggregate check will not help much. Such a decision was purely an Actor making a decision based on the information they had. What would happen in that scenario? |
The case where the aggregate's current version is less than the expected version is only really possible in a multi-node deployment where you have the same aggregate instance process running on different nodes and one of these receives the command but hasn't yet received the most recent event(s). Therefore it's state is stale due to eventual consistency of events being published to all nodes. In this scenario it is acceptable to attempt to fetch any missing events and then do the expected version check again. This time the aggregate's version should be equal to the expected version (accept command) or could be greater than the expected version (reject command). If the aggregate version is still less than the expected version then the command can be rejected too. |
From the Slack conversation, The [expected_version: {:gte, 20}] Supported Filter
|
@slashdotdash @yordis hello! I've been reading up on Elixir and Commanded and hope to use it for a startup soon, would love to help with closing out this issue! For the Thoughts on typing |
I would go for that, but either way, it would work. I suggest making it work first, and then you can bikeshed over the final version. Go with your gut feeling for now! |
@yordis or @slashdotdash could I get contributor access to push up a pull request branch addressing the issue? Thanks! |
@mksaga I will suggest forking the repository. Push the branch to your repository fork and then create a PR. (Also, I do not have access to the Org at all, I am just another external contributor) |
Add support for including the aggregate's expected version when dispatching a command.
If the aggregate's version:
{:error, wrong_expected_version}
);By default the
expected_version
option should be passed as:any_version
to match the current behaviour.Example
The text was updated successfully, but these errors were encountered: