Finish plugin and routing overhaul, there's a new model in town:

* Plugins all derive from Omnibot.Plugin. There still is a base plugin,
  in case we want to have another plugin backend instead of a GenServer
* All plugins are monitored by a unique Plugin.Supervisor, which is in
  turn started by the PluginSupervisor (yes this is confusing, yes it
  needs to be renamed)
* Any other auxiliary child processes may be started through the
  Plugin.children/1 function.
* By default, plugins have a CfgState process which is an Agent that
  keeps track of the plugin's configuration and state
* Plugin API is now called through the GenServer backend for better
  synchronicity.
* Very few changes to the front-facing Plugin API, which is nice

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-14 15:05:00 -07:00
parent 9679c46e15
commit 522c62a55c
6 changed files with 67 additions and 43 deletions

View File

@@ -5,23 +5,8 @@ defmodule Omnibot.Contrib.Wordbot do
@default_config wordbot_source: "words.txt", wordbot_db: "wordbot.db", words_per_round: 300, hours_per_round: 5
#def start_link(opts) do
#Supervisor.start_link(__MODULE__, opts[:cfg], opts)
#end
#@impl true
#def init(cfg) do
# children = [
# {Task.Supervisor, name: Omnibot.Contrib.Wordbot.Watchers, strategy: :one_for_one},
# Wordbot.Db.child_spec(cfg[:wordbot_db]),
# {Wordbot.Bot, cfg: cfg, name: Omnibot.Contrib.Wordbot.Bot},
# ]
# Supervisor.init(children, strategy: :one_for_all)
#end
@impl true
def children(cfg, _state) do
def children(cfg) do
[
{Task.Supervisor, name: Omnibot.Contrib.Wordbot.Watchers, strategy: :one_for_one},
Wordbot.Db.child_spec(cfg[:wordbot_db]),