Creating a supervisor to start other servers?
ramontayag opened this issue · comments
In .iex.exs
, three servers are started:
LndClient.Tools.HtlcUpdates.start_link
LndClient.Tools.InvoiceUpdates.start_link
LndClient.Tools.ChannelUpdates.start_link
What do you think about having a supervisor manage these?
defmodule LndClient.Application do
@moduledoc false
use Application
@impl true
def start(_type, args) do
children = [
LndClient.Tools.HtlcUpdates,
LndClient.Tools.InvoiceUpdates,
LndClient.Tools.ChannelUpdates,
]
opts = [strategy: :one_for_one, name: LndClient.Supervisor]
Supervisor.start_link(children, opts)
end
end
Then in the mix file we make the appropriate changes:
def application do
[
mod: LndClient.Application,
]
end
Since I hope to use this in a Phoenix app, this should just start all the apps under LndClient
, such that they can be called to get info like invoice updates (will ask about this in a separate issue btw).
lnd_client
is meant to me a library of functions and GenServers that can be used by an application as a dependency.
Said applications are free to use any combination of features from lnd_client
. What you are proposing:
- Creates an application straight in the library
- Is a specific case making use of
htlc
s,invoices
, andchannels
at the same time
I'd recommend to apply those recommendations in your Phoenix app rather than in this lib.
Thanks! Your reply to #8 clarifies this.