View Source Yggdrasil.Adapter (Yggdrasil v6.0.2)

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

adapter-alias

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 :my_adapter as a Channel adapter to subscribe and publish with MyAdapter e.g:

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

Link to this section Summary

Types

Adapter types.

Functions

Checks that the module exists.

Generates module given an adapter module and a type.

Link to this section Types

Specs

type() :: Subscriber | Publisher

Adapter types.

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.
Link to this function

check_module(adapter, module)

View Source

Specs

check_module(module(), module()) :: {:ok, module()} | {:error, term()}

Checks that the module exists.

Link to this function

generate_module(adapter, type)

View Source

Specs

generate_module(module(), type()) :: {:ok, module()} | {:error, term()}

Generates module given an adapter module and a type.