1defmodule Drinkup do
2 use Supervisor
3
4 @type options() :: %{
5 required(:consumer) => module(),
6 optional(:host) => String.t(),
7 optional(:cursor) => pos_integer()
8 }
9
10 @spec start_link(options()) :: Supervisor.on_start()
11 def start_link(options) do
12 Supervisor.start_link(__MODULE__, options, name: __MODULE__)
13 end
14
15 def init(options) do
16 children = [
17 {Task.Supervisor, name: Drinkup.TaskSupervisor},
18 {Drinkup.Socket, options}
19 ]
20
21 Supervisor.init(children, strategy: :one_for_one)
22 end
23end