diff --git a/lib/plugin/meta.ex b/lib/plugin/meta.ex deleted file mode 100644 index 0270b37..0000000 --- a/lib/plugin/meta.ex +++ /dev/null @@ -1,37 +0,0 @@ -defmodule Omnibot.Plugin.Meta do - defmodule Hooks do - defmacro __before_compile(_env) do - quote do - def children(_cfg), do: [] - end - end - end - - defmacro __using__([]) do - quote do - use Omnibot.Plugin.Base - use Supervisor - - @behaviour Omnibot.Plugin.Meta - - ## Client API - - def start_link(opts) do - Supervisor.start_link(opts) - end - - ## Server callbacks - def init(opts) do - cfg = opts[:cfg] - children = children(cfg) - Supervisor.init(children, opts) - end - - defoverridable Omnibot.Plugin.Meta - - @before_compile Omnibot.Plugin.Meta.Hooks - end - end - - @callback children(cfg :: any) :: [{atom(), [{atom(), any}]}] -end diff --git a/lib/plugin/supervisor.ex b/lib/plugin/supervisor.ex deleted file mode 100644 index 63158ab..0000000 --- a/lib/plugin/supervisor.ex +++ /dev/null @@ -1,40 +0,0 @@ -defmodule Omnibot.Plugin.Supervisor do - defmacro __using__(_opts) do - quote do - import Omnibot.Plugin.Supervisor - alias Omnibot.Plugin - use Supervisor - - @behaviour Omnibot.Plugin.Supervisor - - def start_link(opts) do - Supervisor.start_link(__MODULE__, opts[:cfg], opts) - end - - def init(_cfg) do - Supervisor.init(children(), strategy: :one_for_one) - end - - end - end - - @callback children() :: [any] -end - -# TODO : -# - figure out the best way to allow for including of supervisors and agents into a bot module -# - have to `use Agent` both places, this is not optimal -# - probably just lacks child_spec/1 ? -# - Do away with actual Plugin.Agent set of functions (outside of macro), -# and make it behaviours + `use Plugin.Agent` instead? -# Allow for ergonomic supervisor declarations, maybe like: -# -# Plugin.supervisor [ -# SomeAgent, -# SomeGenSever, -# SomeWorker, -# ], strategy: one_for_all -# -# -# And it implements all of the stuff for you? This may be too broad for how I'm doing things -# - rename MODULES to PLUGINS