Open andybritz opened 5 years ago
Currently we have an invalid sequence handler strategy, that currently is driven off the enum value InvalidSequenceStrategy
, which can either be LastWriteWins
or Strict
.
LastWriteWins
disables sequence checking completely, whereas Strict
enables it for everything.
Ideally we want something in between. For example, we should be able to credit an account (i.e. increase balance) as many times as we like without caring about the current sequence. If shouldn't either necessarily disrupt an account debit command that contains the sequence number of the previous debit, even if it make a debit account command sequence out of date.
For this strategy we really want to be able to label some commands as safe, and some as unsafe.
(LastWriteWins
above means all are safe, Strict
means all are unsafe).
Then a command should be considered valid if either.
To implement this probably requires storing two sequence numbers with the aggregate - the latest sequence number, and in addition the latest unsafe sequence number.
It would be great if we could add some API/Helper methods for conflict resolution when there is an optimistic concurrency error. This really should be a potential addition to the CommandHandler for any specific command.