EasyRpc.RpcCall (EasyRpc v0.9.0)

Copy Markdown View Source

Core module for executing remote procedure calls.

Handles RPC execution with:

  • Configurable error handling (tuple vs. raise)
  • Automatic retries with per-attempt logging
  • Node selection via NodeSelector
  • Timeout management via :erpc
  • Detailed structured logging at every stage

Implements EasyRpc.Behaviours.RpcExecutor.

Examples

config = WrapperConfig.new!(node_selector, RemoteModule, 5_000, 3, true)

{:ok, result}    = EasyRpc.RpcCall.execute(config, :get_data, ["key"])
{:error, reason} = EasyRpc.RpcCall.execute(config, :missing_fn, [])

Summary

Functions

Executes an RPC call using the given WrapperConfig.

Executes with a dynamically resolved NodeSelector.

Executes an RPC call with automatic retry. Always uses error handling.

Backward-compatible alias for execute/3.

Types

args()

@type args() :: list()

config_ref()

@type config_ref() :: {app :: atom(), config_name :: atom()}

function_name()

@type function_name() :: atom()

raw_result()

@type raw_result() :: term()

result()

@type result() :: {:ok, term()} | {:error, EasyRpc.Error.t()}

Functions

execute(config, function, args)

@spec execute(EasyRpc.WrapperConfig.t(), function_name(), args()) ::
  result() | raw_result()

Executes an RPC call using the given WrapperConfig.

Delegates to error-handling or bare execution based on config.error_handling and config.retry.

Returns {:ok, result} | {:error, Error.t()} with error handling, or the raw result (raising on failure) without.

execute_dynamic(config, arg, function, args)

@spec execute_dynamic(
  EasyRpc.WrapperConfig.t(),
  config_ref(),
  function_name(),
  args()
) ::
  result() | raw_result()

Executes with a dynamically resolved NodeSelector.

Loads the node selector at call-time from {app, config_name} rather than compile-time. Useful when cluster topology changes at runtime.

execute_with_retry(config, function, args)

@spec execute_with_retry(EasyRpc.WrapperConfig.t(), function_name(), args()) ::
  result()

Executes an RPC call with automatic retry. Always uses error handling.

Returns {:ok, result} | {:error, Error.t()}.

rpc_call(config, arg)

@spec rpc_call(
  EasyRpc.WrapperConfig.t(),
  {function_name(), args()}
) :: result() | raw_result()

Backward-compatible alias for execute/3.

rpc_call_dynamic(config, config_ref, arg)

@spec rpc_call_dynamic(
  EasyRpc.WrapperConfig.t(),
  config_ref(),
  {function_name(), args()}
) ::
  result() | raw_result()

Backward-compatible alias for execute_dynamic/4.