-
Notifications
You must be signed in to change notification settings - Fork 0
Description
User Story
As a developer, I want to be notified if a source module doesn't have a mapping so that I have awareness that my program can deadlock.
Description
The following code will cause a deadlock if the source module (__MODULE__) isn't mapped to a target. Since this design is the proxy pattern, the deadlock is normal and expected behavior, as resolve(__MODULE__) resolves to MyInterface.
defmodule MyInterface do
use Resolve
def some_command, do: resolve(__MODULE__).some_command
end However, a developer can either forget to set or accidentally remove a mapping in this case. It would be convenient for Resolve to notify the developer when a mapping doesn't exist for a proxy module. However, we don't want to notify for all missing mappings, as falling back to the original module is desired in non-proxy scenarios.
Design
Add a warn_if_not_mapped boolean flag that will display a warning at compile time if a mapping in this module is not set.
defmodule MyInterface do
use Resolve, warn_if_not_mapped: true
def some_command, do: resolve(__MODULE__).some_command
end warning: Resolve has no mapping for MyInterface
filename.ex:4