Current section
Files
Jump to
Current section
Files
lib/event_bus_metrics/application.ex
defmodule EventBus.Metrics.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
alias EventBus.Metrics.{Config, Counter}
alias EventBus.Metrics.Ticker.{Topic, Topics, Subscribers}
alias EventBus.Metrics.Web.ServerSupervisor
def start(_type, _args) do
import Supervisor.Spec, warn: false
children =
[
worker(Counter, [], id: make_ref(), restart: :permanent),
worker(Topic, [], id: make_ref(), restart: :permanent),
worker(Topics, [], id: make_ref(), restart: :permanent),
worker(Subscribers, [], id: make_ref(), restart: :permanent)
] ++ http_server_supervisor()
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: EventBus.Metrics.Supervisor]
link = Supervisor.start_link(children, opts)
EventBus.subscribe({EventBus.Metrics, [".*"]})
link
end
defp http_server_supervisor do
import Supervisor.Spec, warn: false
case Config.http_server?() do
true -> [supervisor(ServerSupervisor, [])]
false -> []
end
end
end