liveBook · Manning

:rpc.call/4

As explained in Elixir in Action, Third Edition

rpc.call/4 is an Erlang remote procedure call function that invokes a specified function on a remote node.

Distributed systems often need a remote function’s result rather than a fire-and-forget process. :rpc.call/4 performs that request across Erlang nodes. section 12.1.5

Pass the target node and an MFA—module, function, and argument list—to invoke the function remotely. For example, calling Kernel.abs(-1) on node2 returns 1. section 12.1.5

Underneath, :rpc sends the MFA to the target node’s registered :rex process, which applies the function and sends the response back. Helpers also support calls across multiple nodes. section 12.1.5

iex(node1@localhost)1> :rpc.call(:node2@localhost, Kernel, :abs, [-1])
1

A minimal IEx listing shows the node, module, function, arguments, and returned value in one remote call. section 12.1.5

How Elixir in Action, Third Edition covers it

How deep it goes
Explains MFA invocation and the :rex message path, while deferring broader helper behavior to other distribution services.
Examples
Demonstrates remotely evaluating Kernel.abs(-1) on node2 from an IEx session on node1.
What it assumes
Assumes distributed Erlang nodes and MFA familiarity while contrasting the mechanism with low-level Node.spawn.
What you can do after
Apply it via Erlang’s :rpc module to invoke a function remotely and obtain its result.
How it connects
Connects remote procedure calls with Node.spawn, message passing, Erlang nodes, and process registration.

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.