Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leo-project/leo_rpc
An original RPC library written in Erlang whose interface is similar to Erlang's buildin RPC.
https://github.com/leo-project/leo_rpc
erlang leofs library rpc
Last synced: about 2 months ago
JSON representation
An original RPC library written in Erlang whose interface is similar to Erlang's buildin RPC.
- Host: GitHub
- URL: https://github.com/leo-project/leo_rpc
- Owner: leo-project
- License: apache-2.0
- Created: 2013-06-13T09:34:03.000Z (over 11 years ago)
- Default Branch: develop
- Last Pushed: 2020-05-31T09:23:15.000Z (over 4 years ago)
- Last Synced: 2024-04-23T14:10:04.993Z (8 months ago)
- Topics: erlang, leofs, library, rpc
- Language: Erlang
- Homepage: http://leo-project.net/leofs
- Size: 667 KB
- Stars: 9
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# **leo_rpc**
[![Build Status](https://travis-ci.org/leo-project/leo_rpc.svg?branch=develop)](https://travis-ci.org/leo-project/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.```bash
$ 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.
```erlang
$ 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
``````erlang
$ 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
``````erlang
$ 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.```erlang
%% 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 was sponsored by [Rakuten, Inc.](https://global.rakuten.com/corp/) from 2012 to Dec of 2018.
* LeoProject/LeoFS is sponsored by [Lions Data, Ltd.](https://lions-data.com/) from Jan of 2019.