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/pool/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/pool/supervisor.ex')
-rw-r--r-- | lib/poolparty/pool/supervisor.ex | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/poolparty/pool/supervisor.ex b/lib/poolparty/pool/supervisor.ex index 3132f46..751a942 100644 --- a/lib/poolparty/pool/supervisor.ex +++ b/lib/poolparty/pool/supervisor.ex @@ -2,17 +2,17 @@ defmodule PoolParty.Pool.Supervisor do use Supervisor require Logger - def start_link(pool_size, opts \\ []) do + def start_link(pool_size, event_manager, opts \\ []) do Logger.debug("[#{__MODULE__}]: Starting Work Pool Supervisor") - Supervisor.start_link(__MODULE__, {pool_size}, opts) + Supervisor.start_link(__MODULE__, {pool_size, event_manager}, opts) end - def init({pool_size}) do + def init({pool_size, event_manager}) do Logger.debug("[#{__MODULE__}]: Initializing Work Pool Supervisor") children = (1..pool_size) |> Enum.map(fn (id) -> Logger.debug("[#{__MODULE__}]: Starting child worker: #{id}") - worker(PoolParty.Pool.Worker, [], id: id) + worker(PoolParty.Pool.Worker, [event_manager], id: id) end) supervise(children, strategy: :one_for_one) end |