Created
April 3, 2018 13:51
-
-
Save blackode/ef56c1b4e58043c092eeabdfd23b4af7 to your computer and use it in GitHub Desktop.
a supervisor
This file contains hidden or 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 Bank.Supervisor do | |
use Supervisor | |
def start_link(initial_balance) do | |
bank_supervisor = {:ok, sup} = Supervisor.start_link(__MODULE__, [initial_balance]) | |
start_children(sup, initial_balance) | |
bank_supervisor | |
end | |
def start_children(sup, initial_balance) do | |
{:ok, cache_pid} = | |
Supervisor.start_child(sup, worker(Bank.Cache, [initial_balance])) | |
Supervisor.start_child(sup, worker(Bank, [cache_pid])) | |
end | |
def init(_) do | |
supervise([], strategy: :one_for_one) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment