Socket
Socket
Sign inDemoInstall

amqparty

Package Overview
Dependencies
7
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    amqparty

making microservices fun with amqp


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Install size
2.35 MB
Created
Weekly downloads
 

Readme

Source

AMQParty

All I wanted was to build a great microservices using RabbitMQ. but I can't understand all these terms... and all this boilerplate.. waaaa...

So lets party.

Installing

npm install --save amqparty

Using

const amqparty = require('amqparty');

// Just connect with the amqp library settings
amqparty.connect({ ...amqpProperties }).then(() => {
  console.log("Connected..");
  const send = amqparty.sender({ exchange: 'joe', name: 'userInfo' });

  send({
    some: 'data',
    iWould: 'like to send'
  }).then(data => {
    console.log('got myself: ', data);
  }).catch(err => {
    console.error('oh noes: ', err);
  });
});

Handling data in a service

const { connect, handle } = require('amqparty');

const listen = () => {
  console.log("Started...");
  handle({
    exchange: 'joe',
    name: 'userInfo'
  }, (data, resolve, reject) => {
    // Do your thing here...
    resolve({
      heyYou: 'ohai'
    });
  });
};

connect({ ...amqProperties }).then(listen);

How it works

sender

  • creates a queue('joe', 'userInfo')
  • returns a function that:
    • generates a uuid
    • add a subscriber to the subscribers object:
      • will call the callback
      • unbind the queue
      • remove the subscriber from the subscribers object
    • binds the queue to userInfo.response.${uuid}
    • sends data

handle({ exchange: 'joe', name: 'userInfo' }, callback...)

creates a queue (userInfo) that binds to userInfo.request

Keywords

FAQs

Last updated on 30 May 2015

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