Telegex.Plug.Pipeline (Telegex.Plug v0.3.0) View Source

插件的管道。

存储已安装的插件,并根据安装顺序依次调用插件。

Link to this section Summary

Functions

调用管道中的所有插件。

Returns a specification to start this module under a supervisor.

Install a plug into the pipeline.

Install multiple plugs into the pipeline.

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{plugs: [plug()]}

Link to this section Functions

Specs

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

调用管道中的所有插件。

此方法将按照插件的安装顺序依次调用。有状态插件产生的状态将向后传递,无状态插件不产生状态变化,但会接收变化后的状态值。 注意:除了 :preheater:custom 预设类型的插件,其它的任一有状态插件若进入处理流程(返回非 :ignored 的值),后续所有的无状态插件将不再实际调用。

返回所有插件的调用结果快照。

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

install(plug, options \\ [])

View Source

Specs

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

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.

Uninstall a plug in the pipeline.