Stopsel.Invoker (stopsel v0.1.0) View Source
Routes a message through a router.
This module relies on Stopsel.Router for matching the routes,
which ensures that only active routes will be tried to match against.
Link to this section Summary
Functions
Tries to match a message against the loaded routes of the specified router.
The message can either be a Stopsel.Message struct or any data structure
that implements Stopsel.Message.Protocol.
Same as invoke/2 but also checks that the message starts with the
specified prefix. Returns {:error, :wrong_prefix} otherwise.
Link to this section Types
Specs
prefix_error() :: :wrong_prefix
Specs
reason() :: Stopsel.Router.match_error() | {:halted, Stopsel.Message.t()}
Link to this section Functions
Specs
invoke(Stopsel.Message.t() | term(), Stopsel.Router.router()) :: {:ok, term()} | {:error, reason()}
Tries to match a message against the loaded routes of the specified router.
The message can either be a Stopsel.Message struct or any data structure
that implements Stopsel.Message.Protocol.
Return values
This function will return either {:ok, value} or {:error, reason}
The value in {:ok, value} is the result of the executed command.
The reason in {:error, reason} can be one of the following values
:no_match- No matching route was found for the message{:multiple_matches, matches}- Multiple matching routes where found for the message. This should be avoided.{:halted, message}- The message was halted in the pipeline.
Specs
invoke(Stopsel.Message.t() | term(), Stopsel.Router.router(), String.t()) :: {:ok, term()} | {:error, reason() | prefix_error()}
Same as invoke/2 but also checks that the message starts with the
specified prefix. Returns {:error, :wrong_prefix} otherwise.