Created
February 2, 2016 00:23
-
-
Save localshred/cf92b44b84bff60ede46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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