Anu.Adapter behaviour (Anu v0.2.1)

Copy Markdown View Source

Behaviour for message delivery adapters.

Anu ships with three adapters:

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
end

Then use it on a client:

Anu.Client.new(adapter: MyApp.CustomAdapter, finch: MyApp.Finch)

Summary

Callbacks

deliver(t, t)

@callback deliver(Anu.Message.t(), Anu.Client.t()) ::
  {:ok, Anu.Response.t()} | {:error, Anu.Error.t()}