Builds and executes a middleware pipeline for RPC calls.
A pipeline is an ordered list of {plug_module, opts} tuples. Plugs are
composed inside-out — the first plug in the list is the outermost
middleware and the last plug is the innermost.
Default pipeline
[Retry, Logger, NodeSelector, Executor, ErrorHandler]This replicates the behaviour of the original RpcCall.
Summary
Functions
Composes a pipeline into a single (Context.t() -> Context.t()) function.
Executes a pipeline by composing the plugs into a chain and calling it with the given context.
Default pipeline that mirrors the original RpcCall behaviour.
Runs the default pipeline and returns the final context.
Extracts the final result from a pipeline context.
Convenience: creates a context, runs the pipeline, and extracts the result.
Types
@type t() :: [plug_entry()]
Functions
@spec build_chain(t()) :: (EasyRpc.Context.t() -> EasyRpc.Context.t())
Composes a pipeline into a single (Context.t() -> Context.t()) function.
Plugs are folded right-to-left so that pipeline.first becomes the
outermost middleware.
@spec call(t(), EasyRpc.Context.t()) :: EasyRpc.Context.t()
Executes a pipeline by composing the plugs into a chain and calling it with the given context.
The returned context contains the final state — inspect ctx.result,
ctx.error, and ctx.halted after calling.
@spec default() :: t()
Default pipeline that mirrors the original RpcCall behaviour.
Order (outermost → innermost):
- ErrorHandler — normalises result/error on the context
- Retry — wraps the entire call, re-executes on failure
- NodeSelector — picks a target node
- Logger — logs before and after each attempt
- Executor — calls
:erpc.call
@spec execute(EasyRpc.Context.t()) :: EasyRpc.Context.t()
Runs the default pipeline and returns the final context.
Uses the pre-composed default chain — prefer this over call/2 when running
the default pipeline, since no composition happens per call.
@spec extract_result(EasyRpc.Context.t(), EasyRpc.WrapperConfig.t()) :: term()
Extracts the final result from a pipeline context.
Handles both bare mode (raises on error) and safe mode
(returns {:ok, result} | {:error, error}).
In safe mode, results already normalised by ErrorHandler (tagged tuples)
pass through untouched; anything else is wrapped in {:ok, _}.
@spec run(EasyRpc.WrapperConfig.t(), atom(), list(), t() | nil) :: term()
Convenience: creates a context, runs the pipeline, and extracts the result.
This is the primary entry point used by code-generated wrapper functions.
When pipeline is omitted, the pre-composed default pipeline is used.