View Source Exrpc (exrpc v0.4.0)

Lean Elixir RPC library based on RESP (REdis Serialization Protocol).

To set up, start Exrpc.Server on the server side and Exrpc.Client on the client side.

Server-side

# module with function to be called remotely
defmodule ServerSideModule do
  def hello(name), do: "Hello " <> name
end

# start link or add child spec to your supervisor
Exrpc.Server.start_link(name: HelloRpc, port: 7379, mfa_list: [&ServerSideModule.hello/1])

Client-side

# start link or add child spec to your supervisor
Exrpc.Client.start_link(name: HelloRpc, host: "localhost", port: 7379)

# make a remote function call:
Exrpc.call(HelloRpc, ServerSideModule, :hello, ["world"])

Summary

Types

@type on_call() :: {:badrpc, atom()} | {:badrpc, atom(), binary()} | any()

Functions

Link to this function

call(client, mod, fun, arg, timeout \\ 5000)

View Source
@spec call(Exrpc.Client.t(), module(), atom(), list(), timeout()) :: on_call()

Calls a remote function.

Example

iex> Exrpc.call(:my_client, ServerSideModule, :hello, ["world"])
"Hello world"
Link to this function

loop_call(client, mod, fun, arg, retries \\ 0)

View Source
@spec mfa_list(Exrpc.Client.t()) :: [mfa()]

List available remote functions.

Example

iex> Exrpc.mfa_list(:my_client)
[{ServerSideModule, :hello, 1}]