Behaviour for message delivery adapters.
Anu ships with three adapters:
Anu.Adapters.Meta- production adapter that sends messages via the Meta Cloud APIAnu.Adapters.Local- development adapter that logs messages to the consoleAnu.Adapters.Test- test adapter that sends messages to the current process
Implementing a custom adapter
Implement the deliver/2 callback:
defmodule MyApp.CustomAdapter do
@behaviour Anu.Adapter
@impl true
def deliver(message, client) do
# Your delivery logic here; HTTP calls go through client.finch
{:ok, %Anu.Response{id: "custom_123"}}
end
endThen use it on a client:
Anu.Client.new(adapter: MyApp.CustomAdapter, finch: MyApp.Finch)
Summary
Callbacks
@callback deliver(Anu.Message.t(), Anu.Client.t()) :: {:ok, Anu.Response.t()} | {:error, Anu.Error.t()}