Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Queue v2.0.0
- Republished package under @truesparrow

## Queue v1.0.1
- LICENSE changes.
- README changes.

## Queue v1.0.0
- PLG Works Queue is implemented to publish critical events using EventEmitter and RabbitMQ.
- True Sparrow Queue is implemented to publish critical events using EventEmitter and RabbitMQ.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright © 2022 PLG Works
Copyright © 2022 True Sparrow Systems Pvt. Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Queue

![npm version](https://img.shields.io/npm/v/@plgworks/queue.svg?style=flat)
![npm version](https://img.shields.io/npm/v/@truesparrow/queue.svg?style=flat)

PLG Works Queue helps in publishing and subscribing tasks over [RabbitMQ](https://www.rabbitmq.com/). Internally it uses topic-based exchange.
True Sparrow Queue helps in publishing and subscribing tasks over [RabbitMQ](https://www.rabbitmq.com/). Internally it uses topic-based exchange.

One use-case is to publish tasks for asynchronous processing. For example, **API worker process** can publish tasks which will be taken up by **asynchronous worker processes** which have subscribed for such tasks.

Expand All @@ -12,11 +12,11 @@ One use-case is to publish tasks for asynchronous processing. For example, **API
## Install

```bash
npm install @plgworks/queue --save
npm install @truesparrow/queue --save
```

## Initialize
`configStrategy` is passed to initialize PLG Works Queue. `configStrategy` is an object with `rabbitmq` as a key. The value of `rabbitmq` is an object with following keys:
`configStrategy` is passed to initialize True Sparrow Queue. `configStrategy` is an object with `rabbitmq` as a key. The value of `rabbitmq` is an object with following keys:
- **username** [string] (mandatory) RabbitMQ connection username
- **password** [string] (mandatory) RabbitMQ connection password
- **host** [string] (mandatory) RabbitMQ host
Expand All @@ -27,12 +27,12 @@ npm install @plgworks/queue --save
- **switchHostAfterSec** [integer] (optional) Wait time before switching RMQ host.
- **connectionTimeoutSec** [integer] (optional) Wait time for connection to establish.

Following snippet initializes PLG Works Queue Manager:
Following snippet initializes True Sparrow Queue Manager:

```js
const Queue = require('@plgworks/queue');
const Queue = require('@truesparrow/queue');

// Config Strategy for PLG Works Queue.
// Config Strategy for True Sparrow Queue.
configStrategy = {
'rabbitmq': {
'username': 'guest',
Expand Down Expand Up @@ -79,9 +79,9 @@ const queueManager = await Queue.getInstance(configStrategy);
Following snippet subscribes to specific topics over a queue.

```js
const Queue = require('@plgworks/queue');
const Queue = require('@truesparrow/queue');

// Config Strategy for PLG Works Queue.
// Config Strategy for True Sparrow Queue.
configStrategy = {
'rabbitmq': {
'username': 'guest',
Expand Down Expand Up @@ -184,7 +184,7 @@ subscribe();
Following snippet publishes a task for specific topics.

```js
// Config Strategy for PLG Works Queue.
// Config Strategy for True Sparrow Queue.
configStrategy = {
'rabbitmq': {
'username': 'guest',
Expand All @@ -206,7 +206,7 @@ const message = {
};

// Import the Queue module.
const Queue = require('@plgworks/queue');
const Queue = require('@truesparrow/queue');
const publish = async function() {
const queueManager = await Queue.getInstance(configStrategy);
queueManager.publishEvent.perform(
Expand All @@ -229,7 +229,7 @@ Such tasks can be published by using the `publishAfter` parameter. Internally, w
**Important Note**: Do not use arbitrary values of delays. Internally, the message is stored in a delay specific queue for the waiting duration. As the number of allowed delays increases, so do the number of waiting queues. Having too many queues, can hamper RabbitMQ performance.

```js
// Config Strategy for PLG Works Queue.
// Config Strategy for True Sparrow Queue.
configStrategy = {
'rabbitmq': {
'username': 'guest',
Expand All @@ -251,7 +251,7 @@ const message = {
};

// Import the Queue module.
const Queue = require('@plgworks/queue');
const Queue = require('@truesparrow/queue');
const publish = async function() {
const queueManager = await Queue.getInstance(configStrategy);
queueManager.publishEvent.perform(
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
2.0.0
2 changes: 1 addition & 1 deletion config/coreConstant.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CoreConstants {
* @returns {string}
*/
get icNameSpace() {
return 'PLGWorksQueue';
return 'Queue';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '.',
version = require(rootPrefix + '/package.json').version,
rabbitmqHelper = require(rootPrefix + '/lib/rabbitmq/helper'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/lib/rabbitmq/helper');
require(rootPrefix + '/lib/rabbitmq/connection');
Expand Down
4 changes: 2 additions & 2 deletions lib/formatter/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module lib/formatter/response
*/

const PLGWorksBase = require('@plgworks/base'),
responseHelper = new PLGWorksBase.responseHelper({ moduleName: 'PLGWorksQueue' });
const Base = require('@truesparrow/base'),
responseHelper = new Base.responseHelper({ moduleName: 'Queue' });

module.exports = responseHelper;
6 changes: 3 additions & 3 deletions lib/logger/customConsoleLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*
* @module lib/logger/customConsoleLogger
*/
const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '../..',
coreConstants = require(rootPrefix + '/config/coreConstant');

const Logger = PLGWorksBase.Logger;
const Logger = Base.Logger;

// Following is to ensure that INFO logs are printed when debug is off.
let loggerLevel;
Expand All @@ -18,4 +18,4 @@ if (1 === Number(coreConstants.DEBUG_ENABLED)) {
loggerLevel = Logger.LOG_LEVELS.INFO;
}

module.exports = new Logger('plgworks-queue', loggerLevel);
module.exports = new Logger('truesparrow-queue', loggerLevel);
4 changes: 2 additions & 2 deletions lib/rabbitmq/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module lib/rabbitmq/connection
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '../..',
amqp = require('amqplib/callback_api'),
Expand All @@ -13,7 +13,7 @@ const rootPrefix = '../..',
logger = require(rootPrefix + '/lib/logger/customConsoleLogger'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

const rmqIdToConnectionMap = {},
rmqIdToInProcessRequestsMap = {};
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plgworks/queue",
"version": "1.0.1",
"name": "@truesparrow/queue",
"version": "2.0.0",
"description": "Queue helps publish critical events using EventEmitter and RabbitMQ.",
"main": "index.js",
"scripts": {
Expand All @@ -9,22 +9,22 @@
},
"repository": {
"type": "git",
"url": "https://github.com/PLG-Works/queue.git"
"url": "https://github.com/TrueSparrowSystems/queue.git"
},
"keywords": [
"PLG Works Queue",
"True Sparrow Queue",
"Event Emitter",
"RabbitMQ",
"PubSub"
],
"author": "PLG Works",
"author": "True Sparrow",
"license": "MIT",
"bugs": {
"url": "https://github.com/PLG-Works/queue/issues"
"url": "https://github.com/TrueSparrowSystems/queue/issues"
},
"homepage": "https://github.com/PLG-Works/queue#readme",
"homepage": "https://github.com/TrueSparrowSystems/queue#readme",
"dependencies": {
"@plgworks/base": "1.0.0",
"@truesparrow/base": "2.0.0",
"amqplib": "0.8.0",
"uuid": "8.3.2"
},
Expand Down
4 changes: 2 additions & 2 deletions services/publishEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* @module services/publishEvent
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '..',
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/services/rmqPublish/topic');
require(rootPrefix + '/services/rmqPublish/all');
Expand Down
4 changes: 2 additions & 2 deletions services/rmqPublish/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* @module services/rmqPublish/all
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '../..',
apiErrorConfig = require(rootPrefix + '/config/apiErrorConfig'),
paramErrorConfig = require(rootPrefix + '/config/paramErrorConfig'),
responseHelper = require(rootPrefix + '/lib/formatter/response'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/lib/rabbitmq/connection');

Expand Down
4 changes: 2 additions & 2 deletions services/rmqPublish/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module services/rmqPublish/topic
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '../..',
validator = require(rootPrefix + '/lib/validator/init'),
Expand All @@ -15,7 +15,7 @@ const rootPrefix = '../..',
paramErrorConfig = require(rootPrefix + '/config/paramErrorConfig'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/lib/rabbitmq/connection');

Expand Down
4 changes: 2 additions & 2 deletions services/rmqSubscribe/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module services/rmqSubscribe/Base
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');
const { v4: uuidV4 } = require('uuid');

const rootPrefix = '../..',
Expand All @@ -13,7 +13,7 @@ const rootPrefix = '../..',
logger = require(rootPrefix + '/lib/logger/customConsoleLogger'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/lib/rabbitmq/connection');

Expand Down
4 changes: 2 additions & 2 deletions services/rmqSubscribe/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* @module services/rmqSubscribe/all
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '../..',
SubscriptionBase = require(rootPrefix + '/services/rmqSubscribe/Base'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/lib/rabbitmq/connection');

Expand Down
4 changes: 2 additions & 2 deletions services/rmqSubscribe/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* @module services/rmqSubscribe/topic
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '../..',
SubscriptionBase = require(rootPrefix + '/services/rmqSubscribe/Base'),
logger = require(rootPrefix + '/lib/logger/customConsoleLogger'),
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/lib/rabbitmq/connection');

Expand Down
4 changes: 2 additions & 2 deletions services/subscribeEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* @module services/subscribeEvent
*/

const PLGWorksBase = require('@plgworks/base');
const Base = require('@truesparrow/base');

const rootPrefix = '..',
coreConstant = require(rootPrefix + '/config/coreConstant');

const InstanceComposer = PLGWorksBase.InstanceComposer;
const InstanceComposer = Base.InstanceComposer;

require(rootPrefix + '/services/rmqSubscribe/topic');
require(rootPrefix + '/services/rmqSubscribe/all');
Expand Down
4 changes: 2 additions & 2 deletions test/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const chai = require('chai'),

// Load queue manager service
const rootPrefix = '..',
PLGWorksQueue = require(rootPrefix + '/index'),
Queue = require(rootPrefix + '/index'),
configStrategy = require(rootPrefix + '/test/configStrategy.json');

require(rootPrefix + '/lib/rabbitmq/connection');
Expand All @@ -25,7 +25,7 @@ const getParams = function() {
};

// Create connection.
const queueManagerInstance = PLGWorksQueue.getInstance(configStrategy);
const queueManagerInstance = Queue.getInstance(configStrategy);

describe('Publishing to rabbitMq', async function() {
it('should return promise', async function() {
Expand Down