January 2018
Intermediate to advanced
220 pages
5h 5m
English
The strategies describe a lot of how a supervisor will work with child processes, but they are not the whole story. There are a number of other options we can specify. Those options are stored in the child specification.
Fortunately, we don’t have too much work to do here. The GenServer Behaviour creates a default child specification for us whenever we add the use GenServer line to a module. We can check the child spec for the Game module in IEx with child_spec/1, passing it the argument we want the supervisor to use as it starts a game.
| | iex> alias IslandsEngine.Game |
| | IslandsEngine.Game |
| | |
| | iex> Game.child_spec("Kusama") |
| | %{id: IslandsEngine.Game, |
| | restart: :permanent, |
| | shutdown: 5000, |
| | start: ... |
Read now
Unlock full access