Generates adapter facade functions from an Elixir behaviour.
Use MaxoAdapt in a module and declare required callbacks inside behaviour/1:
defmodule Storage do
use MaxoAdapt, default: Storage.Memory
behaviour do
@callback get(binary()) :: {:ok, term()} | {:error, atom()}
end
endThe resulting module is a normal behaviour and exposes each required callback,
configure/1, and __maxo_adapt__/0. See the configuration guide for the
:compile, :get_compiled, :get_env, and :get_dict dispatch modes.
Summary
Functions
Define the adapter behaviour through callbacks.
A @doc tag can be set for each @callback.
Types
Functions
Define the adapter behaviour through callbacks.
A @doc tag can be set for each @callback.
Each required callback becomes a callable facade function with the callback's documentation and spec.
Example
behaviour do
@doc ~S"""
Get session from storage.
"""
@callback get(token :: binary) :: {:ok, Session.t | nil} | {:error, atom}
end