View Source Eventize.EventSourcedProcess behaviour (eventize v0.1.0)
EventSourcedProcess is a optininated GenServer
that will
use event sourcing to store its state as a sequence of events.
Instead of using the normal handle_call/3
and handle_cast/2
callbacks you can now use execute_call/3
and execute_cast/2
.
These function very similar, but instead of modifying the state
you can return a list of events that should be applied. These
events will be stored using the configured event bus and then
applied to the process using the Eventize.EventSourcedProcess.EventApplyer.apply_event/2
or Eventize.EventSourcedProcess.EventApplyer.apply_event/3
callback.
All stored events will also be read on startup and the
Eventize.EventSourcedProcess.EventApplyer.apply_event/3
functions will be called then as well to make sure that the state
is up to date.