All Projects → lindell → Remote Function

lindell / Remote Function

Licence: mit
Make function calls to remote hosts seamlessly

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Remote Function

Rpc Codec
JSON-RPC 2.0 codec for Go net/rpc standard library
Stars: ✭ 87 (-8.42%)
Mutual labels:  rpc, json-rpc
server
Implement the JSON-RPC 2.0 server specification for @laravel.
Stars: ✭ 154 (+62.11%)
Mutual labels:  json-rpc, rpc
Spooky
An HttpClient based Json RPC 2.0/XML-RPC client for .Net.
Stars: ✭ 16 (-83.16%)
Mutual labels:  json-rpc, rpc
Rpc
Simple RPC style APIs with generated clients & servers.
Stars: ✭ 192 (+102.11%)
Mutual labels:  rpc, json-rpc
Joyrpc
high-performance, high-extensibility Java rpc framework.
Stars: ✭ 290 (+205.26%)
Mutual labels:  rpc, json-rpc
xmlrpcwsc-dotnet
XML-RPC Web Service Client C# implementation
Stars: ✭ 30 (-68.42%)
Mutual labels:  json-rpc, rpc
JsonRpc.Standard
An asynchronous .NET Standard library for JSON RPC client & server implementation.
Stars: ✭ 27 (-71.58%)
Mutual labels:  json-rpc, rpc
Jrpc
JSON-RPC implementation in C++17
Stars: ✭ 113 (+18.95%)
Mutual labels:  rpc, json-rpc
aiohttp-rpc
A simple JSON-RPC for aiohttp
Stars: ✭ 22 (-76.84%)
Mutual labels:  json-rpc, rpc
scala-json-rpc
Let your servers and clients communicate over function calls! JSON-RPC 2.0 library for Scala and Scala.js
Stars: ✭ 38 (-60%)
Mutual labels:  json-rpc, rpc
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+2283.16%)
Mutual labels:  rpc, json-rpc
Getty
a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Stars: ✭ 532 (+460%)
Mutual labels:  rpc, json-rpc
Jsonrpc
The jsonrpc package helps implement of JSON-RPC 2.0
Stars: ✭ 143 (+50.53%)
Mutual labels:  rpc, json-rpc
Ether1
Official Go implementation of The Etho Protocol
Stars: ✭ 41 (-56.84%)
Mutual labels:  json-rpc, rpc
Jsonrpcserver
Process JSON-RPC requests in Python
Stars: ✭ 126 (+32.63%)
Mutual labels:  rpc, json-rpc
coreipc
WCF-like service model API for communication over named pipes and TCP. .NET and node.js clients.
Stars: ✭ 22 (-76.84%)
Mutual labels:  json-rpc, rpc
jsonrpcpp
C++ JSON-RPC 2.0 library
Stars: ✭ 97 (+2.11%)
Mutual labels:  json-rpc, rpc
Vs Streamjsonrpc
The StreamJsonRpc library offers JSON-RPC 2.0 over any .NET Stream, WebSocket, or Pipe. With bonus support for request cancellation, client proxy generation, and more.
Stars: ✭ 421 (+343.16%)
Mutual labels:  rpc, json-rpc
Libjson Rpc Cpp
C++ framework for json-rpc (json remote procedure call)
Stars: ✭ 653 (+587.37%)
Mutual labels:  rpc, json-rpc
Easyrpc
EasyRpc is a simple, high-performance, easy-to-use RPC framework based on Netty, ZooKeeper and ProtoStuff.
Stars: ✭ 79 (-16.84%)
Mutual labels:  rpc

Remote Function

Build Status Coverage Status

Remote Function is a library for making remote procedure calls in an intuitive way. Just declare functions on the server and call them from the client, that's it! If the function errors, the error will seamlessly be transferred to the calling client. This is done via JSON RPC 2.0 which makes it possible to use with other clients. It has no dependencies and works by utilizing Proxies that was introduced with ES6.

Install

npm install remote-function

Example

Server

Initiate a server, then just define your function on the server object.

const server = require('remote-function').createServer();

server.divide = (arg1, arg2) => {
    if (arg2 === 0) {
        throw new Error("Can't divide by zero.");
    }
    return arg1 / arg2;
};

Client

Define where the server is located when creating a client. Then you can just call the function that is defined at the server and you get a promise that returns what the server function will return. If you are on >=Node 8.0.0, you can use it with await if you are within an async function.

const remote = require('remote-function').createClient({ host: '127.0.0.1' });

const result = await remote.divide(12, 3);
console.log(result); // 4

If an error is thrown on the server:

try {
    const result = await remote.divide(12, 0);
    console.log(result); // Will not be reached
} catch (error) {
    // Get the error thrown on the server, including stacktrace
}

Options

Server

Option Default Description
host "0.0.0.0" The host that the server listen on
port 6356 The port that the server listen on
includeStack true Should errors include the server stacktrace?

Client

Option Default Description
host "127.0.0.1" The host that the server listens on
port 6356 The port that the server listens on
headers {} Additional request headers
connectTimeout 0 The socket connection timeout
responseTimeout 0 The response wait timeout

createClient also supports options from http.request(). For example, you can set headers to add extra headers to http request, or auth if you need Basic Authentication. You cannot change http request method.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].