diff options
author | kballou <kballou@devnulllabs.io> | 2014-10-20 18:56:23 -0600 |
---|---|---|
committer | kballou <kballou@devnulllabs.io> | 2014-10-20 18:56:23 -0600 |
commit | 5ba91fecec283003690072773638f2f143a2b0fa (patch) | |
tree | 057a1d695256043546ce652f9419f23f2100ca22 /lib/poolparty/supervisor.ex | |
parent | 482e23b272bbb5221e09634c16ab0be9edd40592 (diff) | |
download | poolparty-5ba91fecec283003690072773638f2f143a2b0fa.tar.gz poolparty-5ba91fecec283003690072773638f2f143a2b0fa.tar.xz |
Add event manager and event notification
The PoolParty module was turned into an application that creates a generic
genEvent server, passing it to the supervisor. The supervisor, in turn,
distributes the genevent server to all child processes, etc.
This allows all processes to send events to the manager for logging, etc.
Diffstat (limited to 'lib/poolparty/supervisor.ex')
-rw-r--r-- | lib/poolparty/supervisor.ex | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/poolparty/supervisor.ex b/lib/poolparty/supervisor.ex index 9995a3d..712f0dc 100644 --- a/lib/poolparty/supervisor.ex +++ b/lib/poolparty/supervisor.ex @@ -2,17 +2,20 @@ defmodule PoolParty.Supervisor do use Supervisor require Logger - def start_link(opts \\ []) do + def start_link(event_manager, opts \\ []) do Logger.debug("[#{__MODULE__}]: Starting Pool Party Supervisor") - Supervisor.start_link(__MODULE__, {}, [name: __MODULE__] ++ opts) + Supervisor.start_link( + __MODULE__, + {event_manager}, + [name: __MODULE__] ++ opts) end - def init(_) do + def init({event_manager}) do Logger.debug("[#{__MODULE__}]: Initializing Pool Party Supervisor") pool_size = Application.get_env(:poolparty, :pool_size) Logger.debug("[#{__MODULE__}]: Pool size: #{pool_size}") - children = [worker(PoolParty.Scheduler, [pool_size]), - worker(PoolParty.Pool.Supervisor, [pool_size])] + children = [worker(PoolParty.Scheduler, [pool_size, event_manager]), + worker(PoolParty.Pool.Supervisor, [pool_size, event_manager])] supervise(children, strategy: :one_for_one) end end |