EasyRpc.Context (EasyRpc v1.0.0)

Copy Markdown View Source

Context struct that flows through an RPC plug pipeline.

Analogous to Plug.Conn, this struct carries all state through the middleware pipeline:

  • config — the %WrapperConfig{} for this call
  • function — the remote function atom
  • args — the list of arguments for the call
  • node — the target node (set by a NodeSelector plug)
  • result — the raw RPC result (set by an Executor plug)
  • error — an %EasyRpc.Error{} when the call fails
  • assigns — a free-form map for plug authors to store metadata
  • halted — when true the pipeline stops and returns the context
  • attempt — current retry attempt number (0-based)

Summary

Functions

Puts a value into the assigns map.

Returns true if the context has an error set.

Halts the pipeline — the context is returned as-is and downstream plugs are skipped.

Creates a new context for an RPC call.

Types

t()

@type t() :: %EasyRpc.Context{
  args: list(),
  assigns: map(),
  attempt: non_neg_integer(),
  config: EasyRpc.WrapperConfig.t() | nil,
  error: EasyRpc.Error.t() | nil,
  function: atom(),
  halted: boolean(),
  node: node() | nil,
  result: term() | nil
}

Functions

assign(ctx, key, value)

@spec assign(t(), atom(), term()) :: t()

Puts a value into the assigns map.

errored?(context)

@spec errored?(t()) :: boolean()

Returns true if the context has an error set.

halt(ctx)

@spec halt(t()) :: t()

Halts the pipeline — the context is returned as-is and downstream plugs are skipped.

new(config, function, args)

@spec new(EasyRpc.WrapperConfig.t(), atom(), list()) :: t()

Creates a new context for an RPC call.