Remove (supervisor) opts from Omnibot.Plugin opts, update Plugin.Supervisor to use :one_for_all strategy by default

Plugin opts no longer contains options for the supervisors that watch
plugins, and said supervisors now adopt the one_for_all strategy. This
is because these servers *generally* need one another to stay alive.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-17 17:37:55 -07:00
parent e88bd58229
commit 880f363792
2 changed files with 2 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
defmodule Omnibot.Plugin do defmodule Omnibot.Plugin do
@default_opts [include_base: true, opts: [strategy: :one_for_one]] @default_opts [include_base: true] # strategy: one_for_all
defmodule CfgState do defmodule CfgState do
use Agent use Agent
@@ -16,7 +16,6 @@ defmodule Omnibot.Plugin do
def update_state(pid, fun, timeout \\ 5000) do def update_state(pid, fun, timeout \\ 5000) do
Agent.update(pid, fn {cfg, state} -> {cfg, apply(fun, [state])} end, timeout) Agent.update(pid, fn {cfg, state} -> {cfg, apply(fun, [state])} end, timeout)
#Agent.update(pid, &{&1, apply(fun, [&1])}, timeout)
end end
end end

View File

@@ -22,6 +22,6 @@ defmodule Omnibot.Plugin.Supervisor do
@impl true @impl true
def init({plugin, cfg}) when is_atom(plugin) do def init({plugin, cfg}) when is_atom(plugin) do
children = plugin.plugin_children(cfg) children = plugin.plugin_children(cfg)
Supervisor.init(children, strategy: :one_for_one) Supervisor.init(children, strategy: :one_for_all)
end end
end end