Current section

Files

Jump to
tai lib tai exchanges accounts_supervisor.ex
Raw

lib/tai/exchanges/accounts_supervisor.ex

defmodule Tai.Exchanges.AccountsSupervisor do
use Supervisor
def start_link([adapter: _, exchange_id: exchange_id, accounts: _] = state) do
name = :"#{__MODULE__}_#{exchange_id}"
Supervisor.start_link(__MODULE__, state, name: name)
end
def init(adapter: adapter, exchange_id: exchange_id, accounts: accounts) do
accounts
|> Enum.map(fn {account_id, credentials} ->
{adapter, [exchange_id: exchange_id, account_id: account_id, credentials: credentials]}
end)
|> Supervisor.init(strategy: :one_for_one)
end
end