Socket
Socket
Sign inDemoInstall

@modulus/rabbit-rpc

Package Overview
Dependencies
13
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @modulus/rabbit-rpc

amqplib wrapper for easier rabbitmq scripting of RPC interface


Version published
Maintainers
7
Install size
760 kB
Created

Readme

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

FAQs

Last updated on 19 Sep 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc