🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@codefresh-io/eventbus

Package Overview
Dependencies
Maintainers
26
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codefresh-io/eventbus

```TS const eventbus = require('cf-eventbus');

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
241
32.42%
Maintainers
26
Weekly downloads
 
Created
Source

cf eventbus

const eventbus = require('cf-eventbus');

eventbus.init({
    bus: {
        url: 'amqp://codefresh.dev', // rabbitmq server
        reconnectInterval: 5
    },
    store: {
        host: 'codefresh.dev', // postgres host
        database: 'postgres', // postgres database
        user: 'postgres', // postgres user
        password: 'postgres' // postgres password
    },
    microServiceName: 'service-name' // client name
});

Graceful shutdown

quit() method can be used to gracefully terminate the bus connection by cancelling all consumers, waiting for all consumers in progress to finish, and then closing the connection. If it's not desired, use quit({ force: true }) to terminate the connection immediately.

const eventbus = require('cf-eventbus');

process.on('SIGTERM', async () => {
    try {
        await eventbus.quit();
        // ...
    } catch (err) {
        // ...
    }
});

It's may be required to perform some additional cleanup after all consumers are cancelled and before the connection is closed. In that case, use the following pattern:

const eventbus = require('cf-eventbus');

process.on('SIGTERM', async () => {
    try {
        await eventbus.cancelAllConsumers();
        await eventbus.waitForConsumersToFinish();
        // perform additional cleanup here, such as waiting for HTTP requests to finish
        await eventbus.quit();
        // ...
    } catch (err) {
        // ...
    }
});

FAQs

Package last updated on 09 Mar 2026

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