Coder Social home page Coder Social logo

spcec / leo_rpc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leo-project/leo_rpc

0.0 1.0 0.0 680 KB

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

Home Page: http://leo-project.net/leofs

License: Apache License 2.0

Makefile 1.29% Erlang 98.02% Shell 0.69%

leo_rpc's Introduction

leo_rpc

Build Status

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.

leo_rpc's People

Contributors

yosukehara avatar mocchira avatar egisatoshi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.