More principled initial peers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
defmodule Frajtano.Agent do
|
||||
alias Frajtano.Peer
|
||||
use GenServer
|
||||
require Logger
|
||||
|
||||
def start_link(args) do
|
||||
GenServer.start_link(__MODULE__, nil, [{:name, __MODULE__} | args])
|
||||
@@ -14,6 +15,12 @@ defmodule Frajtano.Agent do
|
||||
}
|
||||
end
|
||||
|
||||
def initial_peers() do
|
||||
initial_peers = Application.fetch_env!(:frajtano, :initial_peers)
|
||||
|> Enum.map(&GenServer.call(__MODULE__, {:add_peer, &1}))
|
||||
Logger.info("Started initial peers: #{inspect initial_peers}")
|
||||
end
|
||||
|
||||
# select: list of specs, where specs are a tuple of match, guards, and outputs
|
||||
# match is {key, pid, value}, :"$1" is a match variable
|
||||
def peer_paths() do
|
||||
|
||||
@@ -22,6 +22,7 @@ defmodule Frajtano.Supervisor do
|
||||
Frajtano.Agent,
|
||||
{Task.Supervisor, name: Frajtano.ClientSupervisor},
|
||||
{Frajtano.Listener, [Application.fetch_env!(:frajtano, :listen_path)]},
|
||||
{Task, &Frajtano.Agent.initial_peers/0},
|
||||
:systemd.ready(),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user