Spectre.Pipeline (Spectre v0.3.0)

Copy Markdown View Source

Minimal Plug-style pipeline executor for Spectre router stages.

Router pipelines collect evidence rather than immediately executing handlers. This shape lets each plug focus on one strategy (regex, cache, classifier, embedding, arbitration) while the final route decision remains explicit.

defmodule MyApp.RouterPipeline do
  use Spectre.Pipeline

  pipeline do
    plug Spectre.Router.Plugs.Regex
    plug Spectre.Router.Plugs.LocalClassifier
    plug Spectre.Router.Plugs.Arbitrate
    plug Spectre.Router.Plugs.Terminalize
  end
end

Summary

Functions

Imports router pipeline macros into a custom pipeline module.

Initializes pipeline specs.

Initializes pipeline specs and raises on invalid declarations.

Groups router plug declarations.

Adds a router plug declaration to a custom pipeline.

Runs a router context through initialized or ad-hoc plug specs.

Types

plug_spec()

@type plug_spec() :: module() | {module(), keyword()} | Spectre.Pipeline.Spec.t()

Functions

__using__(opts)

(macro)

Imports router pipeline macros into a custom pipeline module.

init_specs(specs)

@spec init_specs([plug_spec()]) ::
  {:ok, [Spectre.Pipeline.Spec.t()]} | {:error, term()}

Initializes pipeline specs.

init_specs!(specs)

@spec init_specs!([plug_spec()]) :: [Spectre.Pipeline.Spec.t()]

Initializes pipeline specs and raises on invalid declarations.

pipeline(list)

(macro)

Groups router plug declarations.

plug(module, opts \\ [])

(macro)

Adds a router plug declaration to a custom pipeline.

plug Spectre.Router.Plugs.Regex
plug Spectre.Router.Plugs.LocalClassifier, classifier_local: MyApp.Classifier

run(context, specs)

@spec run(Spectre.Router.Context.t(), [plug_spec()]) ::
  {:ok, Spectre.Router.Context.t()} | {:error, term()}

Runs a router context through initialized or ad-hoc plug specs.