Created
October 23, 2015 03:46
-
-
Save killme2008/a1ddf2b0fee80f6e137b to your computer and use it in GitHub Desktop.
Elixir supervisor example
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 CounterSupervisor do | |
use Supervisor | |
def start_link(v \\ 0) do | |
Supervisor.start_link(__MODULE__, v) | |
end | |
@counter_name Counter | |
#supervisor callback | |
def init(v) do | |
children = [ | |
worker(Counter, [v, [name: @counter_name]]) | |
] | |
supervise(children, strategy: :one_for_one) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment