yggdrasil v4.0.0 Yggdrasil.Adapter View Source

This module defines a generalization of an adapter (for adapter creation refer to Yggdrasil.Subscriber.Adapter and Yggdrasil.Publisher.Adapter behaviour).

Adapter alias

If you already have implemented the publisher and subscriber adapters, then you can alias the module names in order to publish and subscribe using the same Channel struct.

Let’s say that you have both Yggdrasil.Publisher.Adapter.MyAdapter and Yggdrasil.Subscriber.Adapter.MyAdapter and you want to alias both of this modules to :my_adapter, the you would do the following:

defmodule Yggdrasil.Adapter.MyAdapter do
  use Yggdrasil.Adapter, name: :my_adapter
end

And adding the following to your application supervision tree:

Supervisor.start_link([
  {Yggdrasil.Adapter.MyAdapter, []}
  ...
])

This will allow you to use the following as a Channel to subscribe and publish with your adapters:

%Channel{name: "my_channel", adapter: :my_adapter}

Link to this section Summary

Link to this section Functions

Link to this macro __using__(options) View Source (macro)

Macro for using Yggdrasil.Adapter.

The following are the available options:

  • :name - Name of the adapter. Must be an atom.
  • :transformer - Default transformer module or alias. Defaults to :default
  • :backend - Default backend module or alias. Defaults to :default.
  • :subscriber - Subscriber module. Defaults to Yggdrasil.Subscriber.Adapter.<NAME> where <NAME> is the last part of the current module name e.g. the <NAME> for Yggdrasil.MyAdapter would be MyAdapter. If the module does not exist, then defaults to :elixir.
  • :publisher - Publisher module. Defaults to Yggdrasil.Publisher.Adapter.<NAME> where <NAME> is the last part of the current module name e.g. the <NAME> for Yggdrasil.MyAdapter would be MyAdapter. If the module does not exist, then defaults to :elixir.