agala v2.5.2 Agala.Chain behaviour

The Chain specification. There are two kind of Chains: function Chains and module Chains.

Function Chains

A function Chain is any function that receives a connection and a set of options and returns a connection. Its type signature must be:

(Agala.Conn.t, Agala.Chain.opts) :: Agala.Conn.t

Module Chains

A module Chain is an extension of the function Chain. It is a module that must export:

  • a call/2 function with the signature defined above
  • an init/1 function which takes a set of options and initializes it. The result returned by init/1 is passed as second argument to call/2. Note that init/1 may be called during compilation and as such it must not return pids, ports or values that are not specific to the runtime. The API expected by a module Chain is defined as a behaviour by the Agala.Chain module (this module).

Examples

Here's an example of a function Chain:

#TODO

Here's an example of a module Chain:

#TODO

The Chain pipeline

The Agala.Chain.Builder module provides conveniences for building Chain pipelines.

Link to this section Summary

Link to this section Types

Link to this type

opts()
opts() ::
  binary()
  | tuple()
  | atom()
  | integer()
  | float()
  | [opts()]
  | %{optional(opts()) => opts()}

Link to this section Callbacks

Link to this callback

call(arg1, opts)
call(Agala.Conn.t(), opts()) :: Agala.Conn.t()

Link to this callback

init(opts)
init(opts()) :: opts()