🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

@modulus/rabbit-rpc

Package Overview
Dependencies
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@modulus/rabbit-rpc

amqplib wrapper for easier rabbitmq scripting of RPC interface

0.3.0
latest
Source
npm
Version published
Weekly downloads
2
-77.78%
Maintainers
7
Weekly downloads
 
Created
Source

Rabbit-RPC

version build license

amqplib wrapper for easier rabbitmq scripting of RPC interface

Install

npm install @modulus/rabbit-rpc

Usage

RabbitRPC(url, [options])

The exported function takes the same parameters as amqplib.connect, and returns a object with two exported functions, client and server.

Client(queueName, data, done)

Sends data to queue and yields reply.

const RPC = require('@modulus/rabbit-rpc')(url)

RPC.client('rpc-queue', { message: true }, (err, result) => {
  if (err) throw err

  console.log(`worker returned ${result}`)
})

Server(queueName, worker, [capacity])

Consumes messages on given queue and passes them to worker. When worker calls done acknowledges the message and sends the result to the client.

const RPC = require('@modulus/rabbit-rpc')(url)

RPC.server('rpc-queue', (msg, done) => {
  // do work
  done(null, { result: true })
})

Keywords

amqp

FAQs

Package last updated on 19 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts