Installations
npm install promise-rabbit-rpc
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
6.4.0
NPM Version
3.10.3
Score
58.2
Supply Chain
83.7
Quality
73.5
Maintenance
100
Vulnerability
98.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
dilame
Download Statistics
Total Downloads
2,321
Last Day
1
Last Week
8
Last Month
31
Last Year
145
GitHub Statistics
1 Stars
60 Commits
3 Watching
1 Branches
2 Contributors
Bundle Size
258.64 kB
Minified
61.86 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.4
Package Id
promise-rabbit-rpc@1.0.4
Size
4.46 kB
NPM Version
3.10.3
Node Version
6.4.0
Total Downloads
Cumulative downloads
Total Downloads
2,321
Last day
-66.7%
1
Compared to previous day
Last week
0%
8
Compared to previous week
Last month
158.3%
31
Compared to previous month
Last year
-8.8%
145
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
rabbit-rpc
Bluebird-based promise RabbitMQ RPC using amqp.node
Install
1> npm install promise-rabbit-rpc
example
Establish connection
1const rpc = require('promise-rabbit-rpc')('amqp://localhost');
Promises
handler.js
Lets write a handler, that will return the square of the number.
Note that handler can accept any number of arguments. You can use ES6 spread feature.
Function handler
is fully-fledged element of promise chain. This means that you can throw an error, or return Promise.reject(), and caller instance will recieve it.
Althoug you can return pure value or return Promise.resolve() with value - same result.
1rpc.process('sum', function handler(...numbers) {
2 if(numbers.length === 0) return Promise.reject(new Error('No numbers'));
3 return Promise.resolve(numbers.reduce((a, sum) => sum + a));
4})
Now we can call this handler from any instance. You can catch
errors like if caller and handler are executed on one nodejs process. But actually they can be located in different parts of the globe.
1rpc.promise('sum', 1, 2, 3) 2 .then( res => console.log('The sum is ', res) ) 3 .catch( reason => console.error(reason) )
caller.js
If you don't want to use promise.
1rpc.call('sum', 1, 2, 3, function (err, res) { 2 console.log('The square of 99 is', res); 3}); 4
Multiple types
Send strings, numbers, arrays, objects or buffers. Arguments are serialized to BSON using node-buffalo.
1rpc.call('getFile', __dirname, 'getfile.js', function (err, stats, data) { 2 if (err) { 3 return console.error('Got error', err); 4 } else { 5 console.log('Got file', stats.size, data.length); 6 } 7}); 8 9rpc.handle('getFile', function (dir, filename, callback) { 10 let path = dir + '/' + filename; 11 fs.stat(path, function (err, stats) { 12 if (err) return callback(err); 13 fs.readFile(path, function (err, data) { 14 if (err) return callback(err); 15 callback(null, stats, data) 16 }); 17 }); 18});
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More