EventSourcedBehavior is an Akka Persistence behavior for processing commands, persisting events, and rebuilding state by replaying those events. section 9.2.1
Construct an EventSourcedBehavior with four parameters:
- A unique PersistenceId identifies the persistent actor; Akka Sharding can add entity-type information and prevent identity collisions. section 9.2.1
- State holds the actor's current state, such as a list of cargo items. section 9.2.1
- The command handler receives State and Command, then produces an Effect containing events and the resulting state transition. section 9.2.1
- The event handler applies each Event to State during normal processing and event replay. section 9.2.1
Persistent container
A container actor models CargoAdded events and State(cargos: List[Cargo] = Nil). Commands such as AddCargo and GetCargos provide the write and read interface; persisting an event can be followed by a side effect with Effect.persist(...).thenRun(...). section 9.2.1
