aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/application.ex
blob: 74b0dfda48182f84a96e70d74568c43df6b9af7d (plain) (blame)
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
defmodule Shard.Application do
  @moduledoc """
  Main Shard application.

  Shard is a prototype peer-to-peer comunication platform with data
  synchronization.
  """

  use Application

  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    # Define workers and child supervisors to be supervised
    children = [
      { DynamicSupervisor, strategy: :one_for_one, name: Shard.DynamicSupervisor },
      
      # Networking
      SNet.Addr,
      SNet.Manager,
      SNet.TCPServer,

      # Applications & data store
      Shard.Manager,

      # Keys & identities
      Shard.Keys,
      { Task, fn -> Shard.Keys.get_any_identity end },
    ]

    # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Shard.Supervisor]
    Supervisor.start_link(children, opts)
  end
end