partisan_rpc (partisan v6.0.0)

View Source

Partisan's counterpart of Erlang's rpc module.

This is the **legacy** surface. Like OTP — whose own rpc documentation steers new code to erpc:call/4, erpc:multicall/4 and erpc:send_request/4 — prefer partisan_erpc for new code. rpc is kept because it is the target of the rpc => partisan_rpc rewrite applied to modules derived from OTP sources, and because existing code calls it.

Since OTP 23 the rpc module is implemented on top of erpc, with a thin layer translating exceptions into {badrpc, Reason}. This module mirrors that arrangement, and mirrors OTP's split exactly:

  • call, cast, multicall, async_call/yield/nb_yield are shims over partisan_erpc, which runs each request in its own process on the target.
  • block_call, abcast, sbcast and eval_everywhere go to partisan_rpc_backend — the counterpart of OTP's rex server, which OTP likewise still keeps for exactly these operations. block_call in particular is *defined* as executing on that server, serialised with other block_calls; that is what distinguishes it from call.

Summary

Types

error_reason/0

-type error_reason() :: timeout | any().

key/0

-opaque key()

Functions

abcast(Name, Message)

-spec abcast(atom(), any()) -> abcast.

abcast(Nodes, Name, Message)

-spec abcast([node()], atom(), any()) -> abcast.

async_call(Node, Module, Function, Arguments)

-spec async_call(node(), module(), atom(), [any()]) -> key().

async_call(Node, Module, Function, Arguments, Opts)

-spec async_call(node(), module(), atom(), [any()], partisan_peer_service_manager:forward_opts()) ->
                    key().

block_call(Node, Module, Function, Arguments)

-spec block_call(node(), module(), atom(), [any()]) -> any() | {badrpc, error_reason()}.

Evaluates Module:Function(Arguments) on Node, **in the partisan_rpc_backend process itself**.

Unlike call/4 this is serialised with every other block_call on the target and blocks that server for the duration. That serialisation is the defining semantic of block_call — not an implementation accident — which is why OTP also still routes it through rex rather than through erpc.

block_call(Node, Module, Function, Arguments, Timeout)

-spec block_call(node(), module(), atom(), [any()], timeout()) -> any() | {badrpc, error_reason()}.

call(Node, Module, Function, Arguments)

-spec call(Node :: node(), Module :: module(), Function :: atom(), Arguments :: [any()]) ->
              Reply :: any() | {badrpc, error_reason()}.

call(Node, Module, Function, Arguments, Timeout)

-spec call(Node :: node(),
           Module :: module(),
           Function :: atom(),
           Arguments :: [any()],
           Timeout :: timeout() | partisan_peer_service_manager:forward_opts()) ->
              Reply :: any() | {badrpc, error_reason()}.

cast(Node, Module, Function, Arguments)

-spec cast(Node :: node(), Module :: module(), Function :: atom(), Arguments :: [any()]) -> true.

cast(Node, Module, Function, Arguments, Opts)

-spec cast(Node :: node(),
           Module :: module(),
           Function :: atom(),
           Arguments :: [any()],
           Opts :: partisan_peer_service_manager:forward_opts()) ->
              true.

eval_everywhere(Module, Function, Arguments)

-spec eval_everywhere(module(), atom(), [any()]) -> abcast.

eval_everywhere(Nodes, Module, Function, Arguments)

-spec eval_everywhere([node()], module(), atom(), [any()]) -> abcast.

forward_opts(Opts0)

-spec forward_opts(map()) -> map().

Resolves the forward_opts() for a call: the caller's options merged over the globally configured forward_options.

**Per-call options win.** The global value only fills in keys the caller did not specify. This previously read partisan_config:get(forward_options, CallerOpts), which inverts the precedence — partisan_config:get/2 returns the *configured* value whenever one is set, so the caller's channel and partition_key were silently discarded as soon as anything set the global. partisan_pluggable_peer_service_manager:forward_message/4 has always merged in this order; this brings RPC in line with it.

multicall(Module, Function, Arguments)

-spec multicall(module(), atom(), [any()]) -> {[any()], [node()]}.

multicall(Nodes, Module, Function, Arguments)

-spec multicall([node()] | module(), module() | atom(), atom() | [any()], [any()] | timeout()) ->
                   {[any()], [node()]}.

multicall(Nodes, Module, Function, Arguments, TimeoutOrOpts)

-spec multicall([node()],
                module(),
                atom(),
                [any()],
                timeout() | partisan_peer_service_manager:forward_opts()) ->
                   {[any()], [node()]}.

nb_yield(Key)

-spec nb_yield(key()) -> {value, any()} | timeout.

nb_yield(Key, Tmo)

-spec nb_yield(key(), timeout()) -> {value, any()} | timeout.

prepare_opts(L)

-spec prepare_opts(list() | map()) -> map().

sbcast(Name, Message)

-spec sbcast(atom(), any()) -> {[node()], [node()]}.

sbcast(Nodes, Name, Message)

-spec sbcast([node()], atom(), any()) -> {[node()], [node()]}.

yield(Key)

-spec yield(key()) -> any() | {badrpc, error_reason()}.