Yggdrasil v5.0.2 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 :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

Link to this type

type()

View Source
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
check_module(module(), module()) :: {:ok, module()} | {:error, term()}

Checks that the module exists.

Link to this function

generate_module(adapter, type)

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

Generates module given an adapter module and a type.