Packages
counterpoint
0.1.0
Vertical slicing for Elixir — features as self-contained slices using event sourcing and CQRS
Current section
Files
Jump to
Current section
Files
lib/counterpoint/automation/automation.ex
defmodule Counterpoint.Automation do
@callback query() :: Counterpoint.Query.t()
@callback handle(envelope :: Counterpoint.Envelope.t(), store_name :: atom()) :: term()
defmacro __using__(opts) do
store = Keyword.fetch!(opts, :store)
queue_opt = Keyword.get(opts, :queue, nil)
quote do
@behaviour Counterpoint.Automation
def __store__, do: unquote(store)
def __queue__ do
unquote(queue_opt) ||
Application.fetch_env!(:counterpoint, :queue)
end
def child_spec(_opts) do
%{
id: {Counterpoint.Automation.Watcher, __MODULE__},
start: {Counterpoint.Automation.Watcher, :start_link, [[automation_module: __MODULE__]]},
restart: :permanent
}
end
defoverridable child_spec: 1
end
end
end