Packages

Brook provides an event stream client interface for distributed applications. Brook sends and receives messages with the event stream via a driver module and persists an application-specific view of the event stream via a storage module.

Current section

Files

Jump to
brook lib brook supervisor.ex
Raw

lib/brook/supervisor.ex

defmodule Brook.Supervisor do
@moduledoc """
A Brook application supervisor, managing the process registry,
storage and driver module processes, and the server process.
"""
use Supervisor
@doc """
Start a Brook supervisor and link it to the current process.
"""
def start_link(opts) do
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
end
@doc """
Initialize the Brook supervisor with all necessary child processes.
"""
def init(opts) do
config =
Brook.Config.new(opts)
|> Brook.Config.store()
children =
[
{Registry, [keys: :unique, name: Brook.Registry]},
{config.storage.module, config.storage.init_arg},
{Brook.Server, config},
{config.driver.module, config.driver.init_arg}
]
|> List.flatten()
Supervisor.init(children, strategy: :one_for_one)
end
end