npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

merapi-plugin-service-rabbit

v0.6.6

Published

Provide RabbitMQ integration interface

Downloads

13

Readme

Merapi Plugin: Service RabbitMQ

Build Status Codacy Badge Codacy Badge

Introduction

This plugin use RabbitMQ for messaging. When subscribing to an event, it will first check if the publisher is RabbitMQ compatible. If so, it will subscribe to that event's queue, otherwise it will create hook that will be called by the publisher.

Installation

Add plugin to dependency list in package.json

{
    "name": "application",
    "version": "1.0.0",
    "dependencies": {
        "merapi-plugin-service-rabbit": "^0.2.0"
    }
}

Configuration

Merapi Application

name: application
version: 0.4.0
plugins:
    - service
    - service-rabbit

RabbitMQ

service:
    rabbit:
        host: localhost
        port: 5672
        prefetch: 5
        maxAttempts: 5
        retryDelay: 5
        namespace: default

prefetch - default to 5

The maximum number of messages sent to the consumer that can be awaiting acknowledgement; once there are prefetch messages outstanding, the server will not send more messages to this consumer until one or more have been acknowledged.

maxAttempts - default to 5

The maximum number of attempts to get target's info.

retryDelay - default to 5000

The delay time between attempts in milliseconds.

namespace - default to default

Kubernetes namespace where the application resides.

Topic Publisher

service:
    publish:
        converse_event: triggerConverseEvent

Topic Subscriber

service:
    subscribe:
        kanal-platform:
            incoming_message: conversationManager.handleIncomingMessage
    registry:
        kanal-platform: http://localhost:5000

Queue Publisher

service:
    queue:
        publish:
            kanal-platform:
                outgoing_message: publishOutgoingMessage
    registry:
        kanal-platform: http://localhost:5000

Queue Subscriber

service:
    queue:
        subscribe:
            dummy_event: dummyManager.handleDummyEvent

Service Info

GET /info

Result:

{
    name: '<name>',
    version: '<version>',
    status: 'ok',
    modules: {
        api: {
            version: '0.2.0',
            status: 'ok'
        },
        pub: {
            version: '0.2.0',
            status: 'ok'
        },
        sub: {
            version: '0.1.0',
            status: 'ok'
        },
        'pub-rabbit': {
            version: '0.1.0',
            status: 'ok'
        }
    },
    api: {},
    events: [
        'incoming_message',
        'outgoing_message'
    ],
    hooks: [
        'yb-core.incoming_message'
    ],
    queues: [
        'publisher.subscriber.incoming_message'
    ],
    exchanges: [
        'publisher.incoming_message',
        'publisher.outgoing_message'
    ]
}

Usage

Merapi Component

  • PUBLISH
class MainCom extends component {
    constructor(triggerOutgoingMessage) {
        super();
        this.triggerOutgoingMessage = triggerOutgoingMessage;
    }
    
    *sendMessage(message) {
        this.triggerOutgoingMessage(message);
    }
}
  • SUBSCRIBE
class MainCom extends component {
    *handleIncomingMessage(message) {
        process(message);
    }
}

Non-merapi component

  • PUBLISH

    • Create an exchange with this format <namespace>.<publisher>.<event>
    • Publish messages to that exchange
  • SUBSCRIBE

    • Create a RabbitMQ queue
    • Bind the queue to an exchange (exchange's name: <namespace>.<publisher>.<event>)
    • Consume its messages

TESTING

In case of you are using custom rabbitmq connection, you can provide an env file as follow:

# filename: ./test/test.env
export RABBIT_HOST=0.0.0.0
export RABBIT_PORT=5672
export RABBIT_USERNAME=root
export RABBIT_PASSWORD=toor

and perform:

source ./test/test.env && npm test