| 1 | # Synchronous Commands |
| 2 | |
| 3 | ## Decision |
| 4 | |
| 5 | We're making all the Command interactions with the mutable entities (`ContractNegotiation` and `TransferProcess`) synchronous. |
| 6 | |
| 7 | ## Rationale |
| 8 | |
| 9 | Asynchronous commands brought in a lot of unuseful complexity, they brought also downsides as: |
| 10 | - commands would need to be persisted for reliability |
| 11 | - their result is currently "lost" so there would be the need for some sort of notification mechanism. |
| 12 | |
| 13 | Make them synchronous will make everything simpler, it would make them align with the current implementation of the |
| 14 | "protocol" services, that are updating the status synchronously on incoming protocol messages. |
| 15 | |
| 16 | ## Approach |
| 17 | |
| 18 | The `CommandHandler` will return a `CommandResult` that will be successful when the command executed correctly, otherwise |
| 19 | will be a failure. |
| 20 | |
| 21 | To avoid conflicts with the state machines, every command handler will need to lease the entity before applying the state |
| 22 | change. If the lease cannot be obtained, the command will fail. |