agala v2.5.1 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 byinit/1
is passed as second argument tocall/2
. Note thatinit/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 theAgala.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.