Skip to content

Commit

Permalink
Reduce compile-time dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnenterprise committed Oct 24, 2022
1 parent 7be1943 commit c47cb2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/commanded/event/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,10 @@ defmodule Commanded.Event.Handler do

@optional_callbacks init: 0, init: 1, error: 3, partition_by: 2

defmacro __using__(opts) do
defmacro __using__(using_opts) do
quote location: :keep do
@before_compile unquote(__MODULE__)
@behaviour Handler
@opts unquote(opts)

@doc """
Start an event handler `GenServer` process linked to the current process.
Expand Down Expand Up @@ -549,7 +548,7 @@ defmodule Commanded.Event.Handler do
into hibernation after a period of inactivity.
"""
def start_link(opts \\ []) do
opts = Keyword.merge(@opts, opts)
opts = Keyword.merge(unquote(using_opts), opts)

{application, name, config} = Handler.parse_config!(__MODULE__, opts)

Expand All @@ -574,7 +573,7 @@ defmodule Commanded.Event.Handler do
"""
def child_spec(opts) do
opts = Keyword.merge(@opts, opts)
opts = Keyword.merge(unquote(using_opts), opts)

spec =
case Keyword.get(opts, :concurrency, 1) do
Expand Down
5 changes: 2 additions & 3 deletions lib/commanded/process_managers/process_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,13 @@ defmodule Commanded.ProcessManagers.ProcessManager do
alias Commanded.ProcessManagers.ProcessRouter

@doc false
defmacro __using__(opts) do
defmacro __using__(using_opts) do
quote location: :keep do
@before_compile unquote(__MODULE__)
@behaviour ProcessManager
@opts unquote(opts)

def start_link(opts \\ []) do
opts = Keyword.merge(@opts, opts)
opts = Keyword.merge(unquote(using_opts), opts)

{application, name, config} = ProcessManager.parse_config!(__MODULE__, opts)

Expand Down

0 comments on commit c47cb2c

Please sign in to comment.