EasyRpc.Behaviours.RpcExecutor behaviour (EasyRpc v0.9.1)

Copy Markdown View Source

Behaviour for RPC execution implementations.

Defines the contract for executing remote procedure calls in the EasyRpc library. Implementations must handle node selection, error handling, retries, and timeouts.

Callbacks

  • execute/3 - Execute an RPC call with the given configuration
  • execute_with_retry/3 - Execute with automatic retry logic
  • validate_config/1 - Optional config pre-validation hook

Summary

Callbacks

Executes an RPC call without automatic retry.

Executes an RPC call with automatic retry logic.

Optional callback for validating configuration before execution.

Types

args()

@type args() :: list()

function_name()

@type function_name() :: atom()

raw_result()

@type raw_result() :: term()

result()

@type result() :: {:ok, term()} | {:error, term()}

Callbacks

execute(config, function, args)

@callback execute(
  config :: EasyRpc.WrapperConfig.t(),
  function :: function_name(),
  args :: args()
) :: result() | raw_result()

Executes an RPC call without automatic retry.

Returns {:ok, result} | {:error, EasyRpc.Error.t()} when error_handling: true, or the raw result (raising on error) otherwise.

execute_with_retry(config, function, args)

@callback execute_with_retry(
  config :: EasyRpc.WrapperConfig.t(),
  function :: function_name(),
  args :: args()
) :: result()

Executes an RPC call with automatic retry logic.

Always returns {:ok, result} | {:error, EasyRpc.Error.t()}.

validate_config(config)

(optional)
@callback validate_config(config :: EasyRpc.WrapperConfig.t()) :: :ok | {:error, term()}

Optional callback for validating configuration before execution.

Returns :ok or {:error, reason}.