Skip to content

Instantly share code, notes, and snippets.

@localshred
Created February 2, 2016 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localshred/cf92b44b84bff60ede46 to your computer and use it in GitHub Desktop.
Save localshred/cf92b44b84bff60ede46 to your computer and use it in GitHub Desktop.
defmodule MySupervisor do
@moduledoc """
Supervisor to manage MyWorker.
"""
use Supervisor
def start_link do
Supervisor.start_link(__MODULE__, [], name: __MODULE__)
end
def init(_args) do
children = [
worker(MyWorker, [], restart: :transient)
]
supervise(children, strategy: :simple_one_for_one)
end
def start_child(%{"topic" => topic}) do
Supervisor.start_child(__MODULE__, [topic])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment