4.6.29 multicall(SitesWithArgs, Timeout)

-spec multicall(multicall_args(),
                timeout()) -> multicall_result(term()).

Call a function on multiple sites in parallel.

Arguments:

  1. SitesWithArgs: a map from RPC target to {Module, Function, Args} tuple.

    Multicall target could be a site ID that is automatically translated to Erlang node, or a tuple containing site ID and an arbitrary term. The latter form allows to make multiple requests towards the same site. Each multicall target can call a different function.

  2. Timeout: abandon waiting for replies after the specified timeout.

Return value:

A map from RPC target to {ok, Return} tuple if the call was successful or an error tuple classy_lib:multicall_error/0.

Example:

classy_lib:multicall(
  #{S => {erlang, node, []} || S <- [S1, S2, SBad]},
  5_000)

returns

#{ S1 => {ok, 'node1@localhost'}
 , S2 => {ok, 'node2@localhost'}
 , SBad => {error, site_is_down}
 }
JavaScript license information