GenServer.multi_call
You're seeing just the function
multi_call
, go back to GenServer module for more information.
Link to this function
multi_call(nodes \\ [node() | Node.list()], name, request, timeout \\ :infinity)
View SourceSpecs
multi_call([node()], name :: atom(), term(), timeout()) :: {replies :: [{node(), term()}], bad_nodes :: [node()]}
Calls all servers locally registered as name
at the specified nodes
.
First, the request
is sent to every node in nodes
; then, the caller waits
for the replies. This function returns a two-element tuple {replies, bad_nodes}
where:
replies
- is a list of{node, reply}
tuples wherenode
is the node that replied andreply
is its replybad_nodes
- is a list of nodes that either did not exist or where a server with the givenname
did not exist or did not reply
nodes
is a list of node names to which the request is sent. The default
value is the list of all known nodes (including this node).
To avoid that late answers (after the timeout) pollute the caller's message queue, a middleman process is used to do the actual calls. Late answers will then be discarded when they arrive to a terminated process.
Examples
Assuming the Stack
GenServer mentioned in the docs for the GenServer
module is registered as Stack
in the :"foo@my-machine"
and
:"bar@my-machine"
nodes:
GenServer.multi_call(Stack, :pop)
#=> {[{:"foo@my-machine", :hello}, {:"bar@my-machine", :world}], []}