Skip to content

An original RPC library written in Erlang whose interface is similar to Erlang's buildin RPC.

License

Notifications You must be signed in to change notification settings

yosukehara/leo_rpc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leo_rpc

An original rpc library, interface of which is similar to Erlang's RPC. Aim to connect with over 100 nodes.

Usage

First clone the leo_rpc repository and create a copy of it. Then, compile them with different 'listen_port' configurations.

$ git clone https://github.com/leo-project/leo_rpc leo_rpc_0
$ cp -r leo_rpc_0 leo_rpc_1
$ cp -r leo_rpc_0 leo_rpc_2
$ cd leo_rpc_0
$ make
$ cd ../leo_rpc_1
$ vi src/leo_rpc.app.src
## Edit 'listen_port' from 13075 to 13076
         {listen_port,    13076},
$ make
$ cd ../leo_rpc_2
$ vi src/leo_rpc.app.src
## Edit 'listen_port' from 13075 to 13077
         {listen_port,    13077},
$ make

Then, start Erlang shells.

$ cd leo_rpc_1
$ erl -pa ./ebin/ ./deps/*/ebin -name '[email protected]'
Erlang R16B03-1 (erts-5.10.4) [source] [64-bit halfword] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
([email protected])1> application:start(leo_rpc).
ok
([email protected])2> leo_rpc:node().
'[email protected]'
([email protected])3> leo_rpc:nodes().
[]
([email protected])4> leo_rpc:port().
13076
$ cd leo_rpc_2
$ erl -pa ./ebin/ ./deps/*/ebin -name '[email protected]'
Erlang R16B03-1 (erts-5.10.4) [source] [64-bit halfword] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
([email protected])1> application:start(leo_rpc).
ok
([email protected])2> leo_rpc:node().
'[email protected]'
([email protected])3> leo_rpc:nodes().
[]
([email protected])4> leo_rpc:port().
13077
$ cd leo_rpc_0
$ erl -pa ./ebin/ ./deps/*/ebin -name '[email protected]'
Erlang R16B03-1 (erts-5.10.4) [source] [64-bit halfword] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
([email protected])1> application:start(leo_rpc).
ok
([email protected])2> leo_rpc:node().
'[email protected]'
([email protected])3> leo_rpc:nodes().
[]
([email protected])4> leo_rpc:port().
13075

Then, we can try various rpc commands as follow.

%% Execute rpc-call to a remote-node
([email protected])5> leo_rpc:call('[email protected]:13076', leo_rpc, node, []).
'[email protected]'
([email protected])6> leo_rpc:nodes().
[node_1]
([email protected])7> leo_rpc:call('[email protected]:13077', leo_rpc, node, []).
'[email protected]'

%% Execute async rpc-call to a remote-node
([email protected])8> RPCKey = leo_rpc:async_call('[email protected]:13076', leo_rpc, node, []).
<0.252.0>
%% Get the value. (You have to type the following expression in 5 senconds after the above commands.)
([email protected])9> leo_rpc:nb_yield(RPCKey).
{value,'[email protected]'}

%% Execute multi-call to plural nodes
([email protected])10> leo_rpc:multicall(['[email protected]:13075', '[email protected]:13076', '[email protected]:13077'], 'leo_date', 'clock', []).
{[1397709777556582,1397709777555220,1397709777555166],[]}

([email protected])11> leo_rpc:nodes().
[node_0,node_1,node_2]
([email protected])12> leo_rpc:status().
{ok,[{node_0,node_0,13075,4,4},
     {node_1,node_1,13076,4,4},
     {node_2,node_2,13077,4,4}]}

License

leo_rpc's license is "Apache License Version 2.0"

Sponsors

LeoProject/LeoFS is sponsored by Rakuten, Inc. and supported by Rakuten Institute of Technology.

About

An original RPC library written in Erlang whose interface is similar to Erlang's buildin RPC.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 98.0%
  • Makefile 1.3%
  • Shell 0.7%