first commit
This commit is contained in:
43
grafana/dashboards/requests/node_modules/sync-rpc/README.md
generated
vendored
Normal file
43
grafana/dashboards/requests/node_modules/sync-rpc/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# sync-rpc
|
||||
|
||||
Run asynchronous commands synchronously by putting them in a separate process
|
||||
|
||||
[](https://travis-ci.org/ForbesLindesay/sync-rpc)
|
||||
[](http://david-dm.org/ForbesLindesay/sync-rpc)
|
||||
[](https://www.npmjs.org/package/sync-rpc)
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install sync-rpc --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### worker.js
|
||||
|
||||
```js
|
||||
function init(connection) {
|
||||
// you can setup any connections you need here
|
||||
return function (message) {
|
||||
// Note how even though we return a promise, the resulting rpc client will be synchronous
|
||||
return Promise.resolve('sent ' + message + ' to ' + connection);
|
||||
}
|
||||
}
|
||||
module.exports = init;
|
||||
```
|
||||
|
||||
```js
|
||||
const assert = require('assert');
|
||||
const rpc = require('sync-rpc');
|
||||
|
||||
const client = rpc(__dirname + '/../test-worker.js', 'My Server');
|
||||
|
||||
const result = client('My Message');
|
||||
|
||||
assert(result === 'sent My Message to My Server');
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user