March 2025
Intermediate to advanced
202 pages
4h 45m
English
Process managers are the inverse of aggregates. A process manager ingests events and produces commands that can either advance or terminate a process. This means that the pure function for a process manager is this:
| | f(state, event) = c0...cn |
The process manager is given its state and a new event and it can then return 0 or more commands. Let’s take a look at an example from a variant of Lunar Frontiers where you want to ensure that the construction process manager requests the spawning of a new building when a construction site is finished.
| | defmodule ConstructionProcessTest do |
| | use ExUnit.Case |
| | |
| | test "process manager spawns buildings" do |
| | input = %{event_type: :construction_completed, |
| | site_x: ... |
Read now
Unlock full access