Per-stream event handling
We learned that an event is the notification of the execution of a command. In general, any action, not only a command execution with workers and queues, can notify events. The purpose is to react (or not) to the event with some tasks and this decision is completely decoupled from the task that has generated it. Note that in this way, we decide if and how by looking just at a single event.
There are some scenarios where we might take decisions because of a group of events that are raised in a period of time. Let's take the login process of a web application as an example.
A user types their username and password into the login form to perform authentication. Authentication fails. The effect of this action is to raise an invalid login event. We are used to locking out a username after three invalid login attempts. We typically implement this process, counting the number of login attempts and storing the counter into the username profile. When login fails and the counter...