Normandy.Cluster
(normandy v1.1.1)
View Source
Optional convenience for wiring the distributed-session infra (Tier 2) into a host supervision tree. Returns child specs for:
- the Horde registry (
SessionRegistry.Horde,members: :auto), - the Horde supervisor (
Turn.Supervisor.Horde,members: :auto), - the
Turn.ResumeReaper(only when both:storeand:template_providerare supplied — eager handoff needs them), and - an optional
libclusterCluster.Supervisor(only when:topologiesis given ANDlibclusteris a dependency of the host app).
Cluster formation remains the host's choice — this is sugar, not a requirement.
Normandy does NOT depend on libcluster; the Cluster.Supervisor spec is added
only if the running system has it loaded (a runtime check), so hosts that wire
their own clustering (or none) are unaffected.
Example (host application.ex)
children = [
MyApp.Repo,
{Normandy.Behaviours.AgentTemplate.Catalog, name: MyApp.AgentTemplates}
] ++
Normandy.Cluster.child_specs(
registry: MyApp.SessionRegistry,
supervisor: MyApp.TurnSupervisor,
store: {Normandy.Behaviours.SessionStore.Postgres, MyApp.Repo},
template_provider: {Normandy.Behaviours.AgentTemplate.Catalog, MyApp.AgentTemplates},
topologies: Application.get_env(:libcluster, :topologies, [])
)
Supervisor.start_link(children, strategy: :one_for_one)
Summary
Functions
Build the distributed-session child specs. Required: :registry, :supervisor
(names/atoms). Optional: :store + :template_provider (enable the reaper),
:topologies (enable libcluster if loaded).
Child specs for the Redis combo (Redis registry + Redis store + local supervisor +
reaper) — Redis as the single distributed dependency. Required: :redix (keyword for
the Redix connection, must include :name), :namespace, :registry (owner name),
:supervisor (local supervisor name). Optional: :template_provider (enables the
ResumeReaper for eager handoff). Cross-node routing still uses Erlang distribution.
Create the Mnesia store tables (host setup, not a child spec). Thin pass-through to
SessionStore.Mnesia.create_tables/1 — call once at boot before serving sessions.
See that function for opts (:entries, :sessions, :copies, :nodes).
Functions
@spec child_specs(keyword()) :: [ Supervisor.child_spec() | :supervisor.child_spec() | map() ]
Build the distributed-session child specs. Required: :registry, :supervisor
(names/atoms). Optional: :store + :template_provider (enable the reaper),
:topologies (enable libcluster if loaded).
@spec redis_child_specs(keyword()) :: [Supervisor.child_spec() | map()]
Child specs for the Redis combo (Redis registry + Redis store + local supervisor +
reaper) — Redis as the single distributed dependency. Required: :redix (keyword for
the Redix connection, must include :name), :namespace, :registry (owner name),
:supervisor (local supervisor name). Optional: :template_provider (enables the
ResumeReaper for eager handoff). Cross-node routing still uses Erlang distribution.
@spec setup_mnesia_store!(keyword()) :: :ok
Create the Mnesia store tables (host setup, not a child spec). Thin pass-through to
SessionStore.Mnesia.create_tables/1 — call once at boot before serving sessions.
See that function for opts (:entries, :sessions, :copies, :nodes).