Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kitten-mq

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitten-mq - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

8

CHANGELOG.md
# Kitten mq
### v0.12.2
*2023-10-04*
- Add missing `ExecReload` parameter to systemd service template
- Remove retry implementation on client-side handlers when the connection to the broker has not yet been established
- Client extends now from EventEmitter with 2 available events :
- `connect` : emit once the client is connected to hosts
- `disconnect` : emit once the client is disconnected from hosts manually
### v0.12.1

@@ -4,0 +12,0 @@ *2023-09-29*

66

lib/client/index.js

@@ -1,7 +0,9 @@

const utils = require('../utils');
const hosts = require('./hosts');
const routes = require('../routes');
const constants = require('../broker/constants');
const util = require('util');
const { EventEmitter } = require('events');
const utils = require('../utils');
const hosts = require('./hosts');
const routes = require('../routes');
const constants = require('../broker/constants');
function kittenMQ () {
const KittenMQ = function () {
let _config = {

@@ -13,2 +15,3 @@ hosts : [],// list of brokers mirror URLs for High Avaibility

};
let _that = this;
let _hosts = null;

@@ -19,4 +22,2 @@ let _handlers = {};

const NB_RETRY_HANDLER_BEFORE_CONNECT = 20;
/**

@@ -79,13 +80,2 @@ * Ack a message

/**
* Execute function once delay is passed (1000ms)
* @param {Function} fn : Binded function to execute
* @param {int} timer : setTimeout delay in ms (default : 1000)
*/
function _retry (fn, timer = 1000) {
setTimeout(() => {
fn.call();
}, timer);
}
/**
* Connect to brokers

@@ -109,2 +99,3 @@ * @param {Object} config

_isConnected = true;
_that.emit('connect');

@@ -124,2 +115,3 @@ if (callback) {

_isConnected = false;
_that.emit('disconnect');
_hosts.disconnect(callback);

@@ -137,8 +129,3 @@ }

*/
function send (channel, data, callback, nbRetry = 0) {
if (!_isConnected && nbRetry <= NB_RETRY_HANDLER_BEFORE_CONNECT) {
const retryFn = send.bind(null, channel, data, callback, ++nbRetry);
return _retry(retryFn);
}
function send (channel, data, callback) {
let _id = utils.randU32Sync();

@@ -171,8 +158,3 @@

*/
function listen (channel, callback, nbRetry = 0) {
if (!_isConnected && nbRetry <= NB_RETRY_HANDLER_BEFORE_CONNECT) {
const retryFn = listen.bind(null, channel, callback, ++nbRetry);
return _retry(retryFn);
}
function listen (channel, callback) {
let _id = utils.randU32Sync();

@@ -266,8 +248,3 @@ // Register handler

*/
function consume (channel, callback, nbRetry = 0) {
if (!_isConnected && nbRetry <= NB_RETRY_HANDLER_BEFORE_CONNECT) {
const retryFn = consume.bind(null, channel, callback, ++nbRetry);
return _retry(retryFn);
}
function consume (channel, callback) {
let _id = utils.randU32Sync();

@@ -378,13 +355,12 @@

return {
connect,
disconnect,
send,
listen,
consume,
isConnected
};
this.connect = connect;
this.disconnect = disconnect;
this.send = send;
this.listen = listen;
this.consume = consume;
this.isConnected = isConnected;
};
util.inherits(KittenMQ, EventEmitter);
module.exports = kittenMQ;
module.exports = () => { return new KittenMQ() };
{
"name": "kitten-mq",
"version": "0.12.1",
"version": "0.12.2",
"description": "message queue system",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -97,2 +97,9 @@ # Kitten MQ

// Instead of mq.connect() callback, we can subscribe to `connect` event
mq.on('connect', () => {
// This event is called only once
console.log('client connected');
});
mq.connect(config);
// Now, you are ready to send message to a specific channel

@@ -141,2 +148,13 @@ // If the broker is not available, it will re-try automatically until the sending queue is full, then the callback is called with errors

// Disconnection
mq.disconnect(() => {
console.log('client disconnected');
});
// Instead of mq.disconnect() callback, we can subscribe to `disconnect` event
mq.on('disconnect', () => {
console.log('client disconnected');
});
mq.disconnect();
```

@@ -222,3 +240,3 @@

## CLI usage
## CLI usage

@@ -244,3 +262,3 @@ To display the CLI helper

To display the list of messages, use the option `-m` :
To display the list of messages, use the option `-m` :
![cli queue list message](./doc/cli_queue_list_message.png)

@@ -247,0 +265,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc