MeshxRpc.Client.Pool.call
call
, go back to MeshxRpc.Client.Pool module for more information.
call(pool, request, args, timeout \\ :infinity, retry \\ 5, retry_sleep \\ 100)
View SourceSpecs
call( pool :: atom(), request :: atom(), args :: list(), timeout :: timeout(), retry :: pos_integer(), retry_sleep :: non_neg_integer() ) :: term() | {:error_rpc, reason :: term()}
Makes a synchronous RPC call request
using workers pool
and waits for reply.
If successful, call/6
returns Kernel.apply(RpcServerMod, request, args)
evaluation result on remote server.
If error occurs during request processing {:error_rpc, reason}
is returned.
User defined RPC server functions should not return results as tuples with first tuple element being :error_rpc
or any atom name starting with :error_rpc
(for example :error_rpc_remote
) as those tuples are reserved by MeshxRpc
internally for error reporting and processing.
Possible request processing errors:
:full
- all client pool workers are busy and pool manager cannot checkout new worker,:killed
- process executing request on remote server was killed because function execution time exceeded allowed timeout (seeMeshxRpc.Server.Pool
option:timeout_execute
),:invalid_cks
- checksum check with user provided checksum function (:cks_mfa
option) failed,:timeout_cks
- checksum calculation timeout,:closed
- client worker received user request before handshake with server was completed,:tcp_closed
- TCP socket connection was closed,:invalid_ref
- request message failed referential integrity check,{:undef, [...]}
- request function not defined on server,:invalid_state
- server or client worker encountered inconsistent critical state,- any
:inet
POSIX Error Codes, - any errors from (de)serialization function.
If remote server does not respond within time specified by timeout
argument, process executing RPC call is killed, the function call fails and the caller exits. Additionally connection to remote server is closed which kills corresponding RPC call process being executed on the server. Please be aware of MeshxRpc.Server.Pool
:timeout_execute
configuration option playing similar role to timeout
function argument on the server side.
If error occurs during request processing and error reason is in list defined by :exec_retry_on_error
configuration option, request will be retried retry
times with randomized exponential back-off starting with retry_sleep
msec.
Example:
iex(1)> MeshxRpc.Client.Pool.call(Example1.Client, :echo, "hello world")
"hello world"
iex(2)> MeshxRpc.Client.Pool.call(Example1.Client, :not_existing, "hello world")
{:error_rpc, {:undef, [...]}}