Nomnom Pumpernickle Muffins

    imicros-transporter

    0.0.4 • Public • Published

    imicros-transporter

    Build Status Coverage Status Development Status

    Two way transporter for Moleculer services

    • actions/responses and registry messages non-persistent via NATS
    • events persistent via kafka

    Installation

    $ npm install imicros-transporter --save
    

    Requires installation of the additional modules nats and kafkajs

    Usage

    const { KafkaNats } = require("imicros-transporter");
    
    const transporterSettings = {
        kafka: {
            brokers: ["192.168.2.124:9092"]
            /* optional: additional settings
            ssl: null,                           // refer to kafkajs documentation
            sasl: null,                          // refer to kafkajs documentation
            retry: {
                 initialRetryTime: 100,          // default 100
                 retries: 8                      // default 8
            }
            */
        },
        nats: {
            url: "nats://192.168.2.124:4222"
            /* optional: additional settings
            user: "admin",
            pass: "1234"
            */
        }
    };
    kafka = new ServiceBroker({ nodeID: uuid(), transporter: new KafkaNats(transporterSettings), disableBalancer: true });
    
    

    Force emittung events always

    If no running service has subscribed an event, it will not be emitted in the current moleculer version.

    To force to emit always - also if no one is listening, we must add a small middleware:

    const { KafkaNats } = require("imicros-transporter");
    const { EventsMiddleware } = require("imicros-transporter");
    
    kafka = new ServiceBroker({ nodeID: uuid(), transporter: new KafkaNats(transporterSettings), disableBalancer: true, middlewares: [EventsMiddleware] });
    
    

    Install

    npm i imicros-transporter

    DownloadsWeekly Downloads

    0

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    118 kB

    Total Files

    20

    Last publish

    Collaborators

    • al66