Telegex.Plug v0.2.2 Telegex.Plug.Pipeline View Source

Plug pipeline.

Cache plug modules in preset categories, and call plug in the pipeline in order.

Link to this section Summary

Functions

Call all plugs in the pipeline.

Get a list of plugs whose preset category is caller.

Returns a specification to start this module under a supervisor.

Get a list of plugs whose preset category is commander.

Get a list of plugs whose preset category is handler.

Install a plug into the pipeline.

Install multiple plugs into the pipeline.

Get a list of plugs whose preset category is preheater.

Uninstall a plug in the pipeline.

Link to this section Types

Specs

install_opts() :: [{:can_repeat, boolean()}]

Specs

plug() :: atom()

Specs

t() :: %Telegex.Plug.Pipeline{
  callers: [plug()],
  commanders: [plug()],
  handlers: [plug()],
  preheaters: [plug()]
}

Link to this section Functions

Specs

call(Telegex.Model.Update.t(), Telegex.Plug.state()) :: [snapshot()]

Call all plugs in the pipeline.

This function always keeps the calling order of commanders => handlers -> caller. The state of the previous call result will be used before the stateful Plug is called.

At the same time, this function will return all the call results of Plug, which are stored in order in a list.

Specs

callers() :: [atom()]

Get a list of plugs whose preset category is caller.

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

commanders() :: [atom()]

Get a list of plugs whose preset category is commander.

Specs

handlers() :: [atom()]

Get a list of plugs whose preset category is handler.

Link to this function

install(plug, options \\ [])

View Source

Specs

install(plug(), install_opts()) :: :ok | :already_installed

Install a plug into the pipeline.

Arguments

  • plug: The name of the module that implements the plug.
  • options
    • can_repeat: Whether to allow repeated installation. The default value is false, and repeated installation is not allowed.

Notes: If the value of the optional parameter can_repeat is false but an existing plug is installed, it will return :already_installed.

Link to this function

install_all(plugs, options \\ [])

View Source

Install multiple plugs into the pipeline.

Arguments

  • plugs: List of plug().
  • options: Refer to the options parameter in the Telegex.Pipeline.install/2 function.

Specs

preheaters() :: [atom()]

Get a list of plugs whose preset category is preheater.

Uninstall a plug in the pipeline.