defmodule Ockam do
  @moduledoc """
  Ockam is a collection tools for building connected systems
  that you can trust.
  """

  use Application

  # Called when the Ockam application is started.
  #
  # This function is called when an application is started using
  # `Application.start/2`, `Application.ensure_started/2` etc.
  #
  @doc false
  def start(_type, _args) do
    if Code.ensure_loaded?(:telemetry) do
      {:ok, _apps} = Application.ensure_all_started(:telemetry)
    end

    # Specifications of child processes that will be started and supervised.
    #
    # See the "Child specification" section in the `Supervisor` module for more
    # detailed information.
    children = [
      Ockam.Router,
      Ockam.Node
    ]

    # Start a supervisor with the given children. The supervisor will inturn
    # start the given children.
    #
    # The :one_for_one supervision strategy is used, if a child process
    # terminates, only that process is restarted.
    #
    # See the "Strategies" section in the `Supervisor` module for more
    # detailed information.
    Supervisor.start_link(children, strategy: :one_for_one, name: __MODULE__)
  end
end
