Skip to content

Instantly share code, notes, and snippets.

@tokafish
Forked from neektza/Connector.ex
Last active February 3, 2016 18:26
Show Gist options
  • Save tokafish/862d117aa27b7f3c517c to your computer and use it in GitHub Desktop.
Save tokafish/862d117aa27b7f3c517c to your computer and use it in GitHub Desktop.
Confused?
defmodule MessageSpammer.Connector do
use Supervisor
def start_link do
Supervisor.start_link(__MODULE__, [])
end
def init(_) do
IO.puts "Starting Connector"
children =
worker(MessageSpammer.Spammer, [{:interval, 1, :pids, clients}], restart: :temporary) ++
client_specifications(100)
supervise(children, strategy: :one_for_one)
end
def client_specifications(cnt) do
worker(MessageSpammer.Client, [%{}])
|> List.repeat(cnt)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment