B2.1.5 · dive 5 of 6 · module B2.1
The supervisor names the systems.
EchoData.Bcs.Supervisor: a comprehension over {name, namespace} pairs builds one PropertyStore child each, id set to the name, run one_for_one. The topology is data.
The idea
echo_data · bcs/supervisor.exEchoData.Bcs.Supervisor turns a list of systems into a running tree. Its init takes a list of {name, namespace} pairs and, for each, builds a child spec for a PropertyStore — passing the name and namespace as start arguments, and using the name as the child id. The supervisor is where the system topology is declared, and it is declared as data.
The strategy is one_for_one, and setting the child id to the name is what makes restarts addressable: each store is known to the supervisor by its name, so a crash restarts exactly that store and no other. Because the tree is a comprehension over a list, adding a system means adding a pair — not editing the supervisor.
Codemojex’s rooms take the same shape. A supervisor over room pairs brings up one store per room, each named by the room’s branded id; a new room is a new pair, a crashed room is one restarted child, and the command workers that drain the lanes hang off the same tree. The supervisor is how a game of many rooms becomes one supervised topology.
The source
echo_data · committed, verbatimecho_data/lib/echo_data/bcs/supervisor.ex — complete, 19 lines
defmodule EchoData.Bcs.Supervisor do
@moduledoc "one_for_one over named property stores. Rung bcs1.1."
use Supervisor
def start_link(stores), do: Supervisor.start_link(__MODULE__, stores, name: __MODULE__)
@impl true
def init(stores) do
children =
for {name, ns} <- stores do
Supervisor.child_spec({EchoData.Bcs.PropertyStore, [name: name, namespace: ns]},
id: name
)
end
Supervisor.init(children, strategy: :one_for_one)
end
endThe doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, and the 3.0 Stream Tier — XADD, XREADGROUP, XACK — with conformance on Valkey.
Redis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, locks, and streams — the judgement layer.
/echo-persistenceEcho Persistence — the durable floor
Beneath the volatile tiers: the Graft page engine built twice, the commit-LSN loop, and the stream archive on Tigris. Where Part I says state lives somewhere, this says where it lives durably.
References
sources · relatedSources
- Erlang/OTP — the supervisor behaviourone_for_one over named stores: the tree that owns a system's existence
- Erlang/OTP — the gen_server behavioura system as a process: one mailbox, one private state, a message-only surface
- Erlang/OTP — the ets modulethe :private :ordered_set table a property store owns behind its boundary
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus