Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcousens/yajrpc
Yet another JSON RPC
https://github.com/dcousens/yajrpc
javascript json-rpc rpc
Last synced: 25 days ago
JSON representation
Yet another JSON RPC
- Host: GitHub
- URL: https://github.com/dcousens/yajrpc
- Owner: dcousens
- License: mit
- Archived: true
- Created: 2015-11-06T06:17:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-14T07:06:50.000Z (about 6 years ago)
- Last Synced: 2024-10-06T00:35:52.528Z (2 months ago)
- Topics: javascript, json-rpc, rpc
- Language: JavaScript
- Size: 26.4 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cryptocoinjs - bitcoin
README
# YAJRPC
[![TRAVIS](https://secure.travis-ci.org/dcousens/yajrpc.png)](http://travis-ci.org/dcousens/yajrpc)
[![NPM](http://img.shields.io/npm/v/yajrpc.svg)](https://www.npmjs.org/package/yajrpc)[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
Yet another JSON RPC (Client)
## Example
``` javascript
let Yajrpc = require('yajrpc')
let rpc = new YajRPC({
url: 'http://localhost:8332',
user: process.env.RPCUSER,
pass: process.env.RPCPASSWORD
})// 1 call
rpc.call('func1', [1, 2, 3], (err, result) => {
// ...
})// batched request
rpc.batch([{
method: 'func1',
params: [1, 2, 3],
callback: (err, result) => {
// ...
}
}, ...], function (err) { ... })
```The `batch` method is remarkably useful in high-performance applications when used with tools like [`qup`](https://github.com/dcousens/qup):
``` javascript
let qup = require('qup')
let Yajrpc = require('yajrpc')let client = new Yajrpc({
url: process.env.RPC,
user: process.env.RPCUSER,
pass: process.env.RPCPASSWORD
})// group RPC calls into batches of RPCBATCHSIZE, with a maximum of RPCCONCURRENT batches simultaneously
let q = qup((batch, callback) => {
client.batch(batch, callback)
}, process.env.RPCCONCURRENT, process.env.RPCBATCHSIZE)function rpc (method, params, callback) {
q.push({ method, params, callback })
}rpc('func1', [1, 2, 3], ...)
```See `yajrpc/qup` for a pre-made equivalent of the above.
## LICENSE [MIT](LICENSE)