Intro
EasyRpc for easy to wrap a remote function (rpc) to local module for convenience. Dev just to need add config for target nodes (or use {Module, :function, args} for get nodes in runtime) and add functions want to wrap then use EasyRpc with option for EasyRpc can read the config. Then call rpc in app like a local function.
This library help developer easy to wrap a remote procedure call (rpc, library uses Erlang
:erpc
module).EasyRpc supports some basic features for wrapping rpc: retry, timeout, error_handling. Each function can has seperated options or use global options (config for all function in a module).
Source code is available on Github and package on Hex
Example
Add Configs
This way you can add config to config.exs/dev/prod.exs or runtime.exs(for runtime).
config :simple_example, :remote_defrpc,
nodes: [:"remote@127.0.0.1"], # or {ClusterHelper, :get_nodes, [:remote_api]},
select_mode: :round_robin
Declare functions
defmodule Remote
use EasyRpc.DefRpc,
otp_app: :simple_example,
config_name: :remote_defrpc,
# Remote module name
module: RemoteNode.Interface,
timeout: 1000
defrpc :get_data
defrpc :put_data, args: 1
defrpc :clear, args: 2, as: :clear_data, private: true, retry: 1
defrpc :put_data, args: [:name], new_name: :put_with_retry, retry: 3, timeout: 3000
end
Now call rpc like a local function
Remote.get_data()
Thanks for reading!