@flowbuild/streamers
TypeScript icon, indicating that this package has built-in type declarations

0.0.12 • Public • Published

FlowBuild Streamers

This library provides functionality for writing and consuming events across multiple brokers

Coverage lines Coverage branches Coverage functions Coverage statements

Dependencies:

It is necessary to have a Message Broker running in order to use the Stream Interface. The available Brokers are:

kafka
bullmq
mqtt
rabbitmq

Install:

npm i @flowbuild/streamers

Configuration:

The required configuration object has a structure similar to:

{
    "topics":{
        "event-topic":{
            "producesTo":["bullmq", "kafka", "mqtt", "rabbitmq"],
            "consumesFrom":["bullmq", "kafka", "mqtt", "rabbitmq"],
        },
    },
    "kafka": {
        "CLIENT_ID": "my-kafka-id",
        "BROKER_HOST": "localhost",
        "BROKER_PORT": "9092",
        "GROUP_CONSUMER_ID": "my-consumer-group",
    },
    "bullmq": {
        "REDIS_HOST": "localhost",
        "REDIS_PORT": "6379",
        "REDIS_PASSWORD": "",
        "REDIS_DB": 4,
    },
    "mqtt": {
        "MQTT_HOST": "localhost",
        "MQTT_PORT": "1883",
        "MQTT_PROTOCOL": "http",
        "MQTT_USERNAME": "username",
        "MQTT_PASSWORD": "password",
    },
    "rabbitmq": {
        "RABBITMQ_HOST": "localhost:5672",
        "RABBITMQ_USERNAME": "user",
        "RABBITMQ_PASSWORD": "password",
        "RABBITMQ_QUEUE": "flowbuild"
    }
}

In topics you must put the name of the events and a relation of Consumption and Production listing the brokers that will be used.

For each broker you want to use, you must put the necessary configuration in the respective configuration key

Example:

const stream = new StreamInterface({
    "topics":{
        "event-topic":{
            "producesTo":["bullmq", "kafka", "mqtt", "rabbitmq"],
            "consumesFrom":["bullmq", "kafka", "mqtt", "rabbitmq"],
        },
    },
    "kafka": {
        "CLIENT_ID": "my-kafka-id",
        "BROKER_HOST": "localhost",
        "BROKER_PORT": "9092",
        "GROUP_CONSUMER_ID": "my-consumer-group",
    },
    "bullmq": {
        "REDIS_HOST": "localhost",
        "REDIS_PORT": "6379",
        "REDIS_PASSWORD": "",
        "REDIS_DB": 4,
    },
    "mqtt": {
        "MQTT_HOST": "localhost",
        "MQTT_PORT": "1883",
        "MQTT_PROTOCOL": "http",
        "MQTT_USERNAME": "username",
        "MQTT_PASSWORD": "password",
    },
    "rabbitmq": {
        "RABBITMQ_HOST": "localhost:5672",
        "RABBITMQ_USERNAME": "user",
        "RABBITMQ_PASSWORD": "password",
        "RABBITMQ_QUEUE": "flowbuild"
    }
});

const consumerCallback = (topic: string, receivedMessage: string) => {
    console.log({topic, receivedMessage});
};

await stream.connect(consumerCallback);
await stream.produce(
    "event-topic", 
    {"mensagem": "This is an test"},
);

await stream.produce(
    "event-topic", 
    {"mensagem": "This is another test"},
);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.122latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.122
0.0.111
0.0.100
0.0.90
0.0.81
0.0.71
0.0.61
0.0.50
0.0.41
0.0.31
0.0.20

Package Sidebar

Install

npm i @flowbuild/streamers

Weekly Downloads

0

Version

0.0.12

License

ISC

Unpacked Size

96.8 kB

Total Files

58

Last publish

Collaborators

  • imagure
  • lucas.biason.fdte
  • wallace.silva.ferreira
  • ricardo.imagure
  • pedropereiraassis
  • fdte_pcasari
  • gustavo_fdte
  • rafgoncalves
  • elson_oliveira
  • bot.flowbuild