Normandy.Agents.Turn.ServerSupervisor behaviour (normandy v2.2.0)

View Source

The contract of the module a Normandy.Agents.Turn.Session starts and stops its Turn.Server through (its :supervisor_mod).

Normandy.Agents.Turn.Supervisor (one node) and Normandy.Agents.Turn.Supervisor.Horde (a cluster) implement it. Turn.Session.new/1 refuses a :supervisor_mod that does not export both callbacks, naming the option; Turn.ResumeReaper and Normandy.Coordination.AgentProcess start servers through the same module.

Summary

Callbacks

Starts a Turn.Server with server_opts (the options of Normandy.Agents.Turn.Server.start_link/1) under supervisor.

Stops the session server pid, a child of supervisor, without a restart. Returns {:error, :not_found} when supervisor has no such child. Turn.Session.delete/1 calls it.

Callbacks

start_server(supervisor, server_opts)

@callback start_server(supervisor :: term(), server_opts :: keyword()) ::
  DynamicSupervisor.on_start_child()

Starts a Turn.Server with server_opts (the options of Normandy.Agents.Turn.Server.start_link/1) under supervisor.

Returns what DynamicSupervisor.start_child/2 returns: {:ok, pid} or {:error, reason} in practice. A server already registered for the session is {:error, {:already_started, pid}} (bare or nested in the supervisor's error); the session routes to pid (see "Start-time race" in Normandy.Agents.Turn.Session).

stop_server(supervisor, pid)

@callback stop_server(supervisor :: term(), pid()) :: :ok | {:error, :not_found}

Stops the session server pid, a child of supervisor, without a restart. Returns {:error, :not_found} when supervisor has no such child. Turn.Session.delete/1 calls it.