New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@package/pubsub

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@package/pubsub

easy peasy rabbitmq

0.0.11
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
5
Weekly downloads
 
Created
Source

pubsub

wrapper around amqplib to help expediate basic stuffs.

Installation


    >$ npm install @package/pubsub

Test


    @package/pubsub>$ npm test

Build

if you want to convert @package/pubsub into es5, you can simply run:


    @package/pubsub>$ npm run build

API

create_connection(config:Object):AMQPConnection

creates a connection.

Example

    import {create_connection} from '@package/pubsub';

    // use an alternate port
    let conn = yield create_connection({ port : 5673 });

init_channel(conn:AMQPConnection, handlers:Object):AMQPChannel

create a channel, assert passed queues in handlers Object into existence and add their callbacks — if any — as consumers.

Example

    import {create_connection, init_channel} from '@package/pubsub';

    let conn = yield create_connection;

    let channel = yield init_channel(conn, {
        // assert queue into existence and consume any messages published to it
        'queue.name.1' : function* (channel, msg) {
            let data = msg.content.toString();

            console.log(msg);

            // if you want to remove this message from the queue
            channel.ack(data);
        },
        // assert queue into existence only
        'queue.name.2' : true
    });

broadcast(channel:AMQPChannel, queue:String, message:Object[, wait:Number]):Void

broadcast a message to the passed queue.

Example

    import {create_connection, init_channel, broadcast} from '@package/pubsub';

    let conn = yield create_connection;

    let channel = yield init_channel(conn, {
        'queue.name.1' : function* (channel, msg) {
            let data = JSON.parse(msg.content.toString());

            let res = yield doSomethingTo(data);

            channel.ack(msg);

            // broadcast the new message to a different queue
            yield broadcast(channel, 'queue.name.2', res);
        },
        'queue.name.2' : true
    });

destroy_queue(conn:AMQPConnection, queue1:String[, queue2:String, ..., , queueN:String]):Void

remove the passed queues, will not throw an Error if a queue does not exist.

Example

    import {conn, destroy_queue} from '@package/pubsub';

    let conn = yield create_connection;

    yield destroy_queue(conn, 'queue.name.1', 'queue.name.2');

Keywords

amqp

FAQs

Package last updated on 16 May 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