Hash :
2e8a3d5b
Author :
Date :
2016-02-18T09:27:48
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
defmodule ExOvh.Ovh.Supervisor do
@moduledoc :false
use Supervisor
alias ExOvh.Ovh.OvhApi.Cache
alias ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor, as: Webstorage
#####################
# Public
#####################
@doc ~S"""
Starts the OVH supervisor.
"""
def start_link(client, config, opts) do
Og.context(__ENV__, :debug)
Supervisor.start_link(__MODULE__, {client, config, opts}, [name: supervisor_name(client)])
end
#####################
# Callbacks
#####################
def init({client, config, opts}) do
Og.context(__ENV__, :debug)
tree = [
{Cache, {Cache, :start_link, [{client, config, opts}]}, :permanent, 10_000, :worker, [Cache]},
{Webstorage, {Webstorage, :start_link, [{client, config, opts}]}, :permanent, 10_000, :supervisor, [Webstorage]}
]
supervise(tree, strategy: :one_for_one, max_restarts: 20)
end
#####################
# Private
#####################
defp supervisor_name(client), do: String.to_atom(Atom.to_string(client) <> Atom.to_string(__MODULE__))
end