December 2019
Intermediate to advanced
248 pages
5h 34m
English
We’re going to break with tradition and use the word lifecycle instead of supervisor. Most Elixir developers think of Elixir’s supervision as a way to handle failure, and it’s easy to see why. Some Erlang deployments using OTP have been up for years at a time. If you’ve been telling yourself that “supervisors are about failure,” we want to help you reshape that idea.
To illustrate, let’s look at some holes in our Counter component. Look at the start function in our counter again:
| | defmodule Counter do |
| | def start(initial_count) do |
| | spawn( fn() -> Counter.Server.run(initial_count) end ) |
| | end |
| | |
| | def tick(pid) do |
| | send pid, {:tick, self()} |
| | end |
| | def state(pid) ... |
Read now
Unlock full access