Fly.RPC (Fly RPC v0.1.1) View Source
Provides an RPC interface for executing an MFA on a node within a region.
Configuration
Assumes each node is running the Fly.RPC
server in its supervision tree and
exports FLY_REGION
environment variable to identify the fly region.
To run code on a specific region call rpc_region/4
. A node found within the
given region will be chosen at random. Raises if no nodes exist on the given
region.
The special :primary
region may be passed to run the rpc against the region
identified by the PRIMARY_REGION
environment variable.
Examples
> rpc_region("hkg", String, :upcase, ["fly"])
"FLY"
> rpc_region(Fly.primary_region(), String, :upcase, ["fly"])
"FLY"
> rpc_region(:primary, String, :upcase, ["fly"])
"FLY"
Server
The GenServer's responsibility is just to monitor other nodes as they enter and leave the cluster. It maintains a list of nodes and the Fly.io region where they are deployed in an ETS table that other processes can use to find and initiate their own RPC calls to.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.handle_continue/2
.
Callback implementation for GenServer.init/1
.
Executes a function on the remote node to determine if the RPC API support is available.
Asks a node what Fly region it's running in. Does this through an RPC call. If
the function for asking isn't supported (code not running there yet), return
an :error
.
Returns the Elixir OTP nodes registered the region. Reads from a local cache.
Executes the function on the remote node and waits for the response up to
timeout
length.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback implementation for GenServer.handle_continue/2
.
Callback implementation for GenServer.init/1
.
Executes a function on the remote node to determine if the RPC API support is available.
Support may not exist on the remote node in a "first roll out" scenario.
Asks a node what Fly region it's running in. Does this through an RPC call. If
the function for asking isn't supported (code not running there yet), return
an :error
.
Returns the Elixir OTP nodes registered the region. Reads from a local cache.
Executes the function on the remote node and waits for the response up to
timeout
length.