@rxdi/rabbitmq-pubsub 0.7.190 → 0.7.191-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/childLogger.js +1 -2
- package/dist/common.js +3 -3
- package/dist/connectionFactory.d.ts +5 -5
- package/dist/connectionFactory.js +7 -7
- package/dist/consumer.d.ts +5 -5
- package/dist/producer.d.ts +6 -7
- package/dist/producer.js +4 -4
- package/dist/publisher.d.ts +7 -8
- package/dist/publisher.js +5 -7
- package/dist/subscriber.d.ts +5 -5
- package/package.json +5 -5
package/dist/childLogger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createChildLogger =
|
|
3
|
+
exports.createChildLogger = createChildLogger;
|
|
4
4
|
function createChildLogger(logger, className) {
|
|
5
5
|
return {
|
|
6
6
|
trace: (...message) => process.env.PUBSUB_LOGGING && console.log(...message),
|
|
@@ -8,4 +8,3 @@ function createChildLogger(logger, className) {
|
|
|
8
8
|
debug: (...message) => process.env.PUBSUB_LOGGING && console.log(...message),
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
exports.createChildLogger = createChildLogger;
|
package/dist/common.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DefaultPubSubQueueConfig = exports.DefaultQueueNameConfig = void 0;
|
|
4
|
+
exports.asQueueNameConfig = asQueueNameConfig;
|
|
5
|
+
exports.asPubSubQueueNameConfig = asPubSubQueueNameConfig;
|
|
4
6
|
class DefaultQueueNameConfig {
|
|
5
7
|
constructor(name) {
|
|
6
8
|
this.name = name;
|
|
@@ -22,13 +24,11 @@ function asQueueNameConfig(config) {
|
|
|
22
24
|
? config
|
|
23
25
|
: new DefaultQueueNameConfig(config);
|
|
24
26
|
}
|
|
25
|
-
exports.asQueueNameConfig = asQueueNameConfig;
|
|
26
27
|
function asPubSubQueueNameConfig(config) {
|
|
27
28
|
return isQueueNameConfig(config)
|
|
28
29
|
? config
|
|
29
30
|
: new DefaultPubSubQueueConfig(config);
|
|
30
31
|
}
|
|
31
|
-
exports.asPubSubQueueNameConfig = asPubSubQueueNameConfig;
|
|
32
32
|
function isQueueNameConfig(config) {
|
|
33
33
|
if (config.name &&
|
|
34
34
|
config.dlq &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Logger } from
|
|
1
|
+
import { ChannelModel } from 'amqplib';
|
|
2
|
+
import { Logger } from './childLogger';
|
|
3
3
|
export interface IRabbitMqConnectionFactory {
|
|
4
|
-
create(): Promise<
|
|
4
|
+
create(): Promise<ChannelModel>;
|
|
5
5
|
}
|
|
6
6
|
export interface IRabbitMqConnectionConfig {
|
|
7
7
|
host: string;
|
|
@@ -12,12 +12,12 @@ export declare class RabbitMqConnectionFactory implements IRabbitMqConnectionFac
|
|
|
12
12
|
private connection;
|
|
13
13
|
connect: any;
|
|
14
14
|
constructor(logger: Logger, config: IRabbitMqConnectionConfig | string);
|
|
15
|
-
create(): Promise<
|
|
15
|
+
create(): Promise<ChannelModel>;
|
|
16
16
|
}
|
|
17
17
|
export declare class RabbitMqSingletonConnectionFactory implements IRabbitMqConnectionFactory {
|
|
18
18
|
private logger;
|
|
19
19
|
private connection;
|
|
20
20
|
private promise;
|
|
21
21
|
constructor(logger: Logger, config: IRabbitMqConnectionConfig | string);
|
|
22
|
-
create(): Promise<
|
|
22
|
+
create(): Promise<ChannelModel>;
|
|
23
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RabbitMqSingletonConnectionFactory = exports.RabbitMqConnectionFactory = void 0;
|
|
4
|
-
const
|
|
4
|
+
const amqplib_1 = require("amqplib");
|
|
5
5
|
const childLogger_1 = require("./childLogger");
|
|
6
6
|
function isConnectionConfig(config) {
|
|
7
7
|
if (config.host &&
|
|
@@ -15,14 +15,14 @@ class RabbitMqConnectionFactory {
|
|
|
15
15
|
this.connection = isConnectionConfig(config)
|
|
16
16
|
? `amqp://${config.host}:${config.port}`
|
|
17
17
|
: config;
|
|
18
|
-
this.logger = (0, childLogger_1.createChildLogger)(logger,
|
|
18
|
+
this.logger = (0, childLogger_1.createChildLogger)(logger, 'RabbitMqConnectionFactory');
|
|
19
19
|
}
|
|
20
20
|
create() {
|
|
21
|
-
this.logger.debug(
|
|
21
|
+
this.logger.debug('connecting to %s', this.connection);
|
|
22
22
|
if (this.connect) {
|
|
23
23
|
return Promise.resolve(this.connect);
|
|
24
24
|
}
|
|
25
|
-
return Promise.resolve(
|
|
25
|
+
return Promise.resolve((0, amqplib_1.connect)(this.connection))
|
|
26
26
|
.then((connect) => {
|
|
27
27
|
this.connect = connect;
|
|
28
28
|
return connect;
|
|
@@ -43,11 +43,11 @@ class RabbitMqSingletonConnectionFactory {
|
|
|
43
43
|
}
|
|
44
44
|
create() {
|
|
45
45
|
if (this.promise) {
|
|
46
|
-
this.logger.trace(
|
|
46
|
+
this.logger.trace('reusing connection to %s', this.connection);
|
|
47
47
|
return this.promise;
|
|
48
48
|
}
|
|
49
|
-
this.logger.debug(
|
|
50
|
-
return (this.promise = Promise.resolve(
|
|
49
|
+
this.logger.debug('creating connection to %s', this.connection);
|
|
50
|
+
return (this.promise = Promise.resolve((0, amqplib_1.connect)(this.connection)));
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.RabbitMqSingletonConnectionFactory = RabbitMqSingletonConnectionFactory;
|
package/dist/consumer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Channel, Message, Options } from "amqplib";
|
|
2
2
|
import { IRabbitMqConnectionFactory } from "./connectionFactory";
|
|
3
3
|
import { IQueueNameConfig } from "./common";
|
|
4
4
|
import { Logger } from "./childLogger";
|
|
@@ -12,8 +12,8 @@ export declare class RabbitMqConsumer {
|
|
|
12
12
|
subscribe<T>(queue: string | IQueueNameConfig, action: (message: T) => Promise<any> | void): Promise<IRabbitMqConsumerDisposer>;
|
|
13
13
|
private setupChannel;
|
|
14
14
|
private subscribeToChannel;
|
|
15
|
-
protected getMessageObject<T>(message:
|
|
16
|
-
protected getChannelSetup(channel:
|
|
17
|
-
protected getQueueSettings(deadletterExchangeName: string):
|
|
18
|
-
protected getDLSettings():
|
|
15
|
+
protected getMessageObject<T>(message: Message): T;
|
|
16
|
+
protected getChannelSetup(channel: Channel, queueConfig: IQueueNameConfig): Promise<import("amqplib").Replies.Empty>[];
|
|
17
|
+
protected getQueueSettings(deadletterExchangeName: string): Options.AssertQueue;
|
|
18
|
+
protected getDLSettings(): Options.AssertQueue;
|
|
19
19
|
}
|
package/dist/producer.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Logger } from "./childLogger";
|
|
1
|
+
import { Options } from 'amqplib';
|
|
2
|
+
import { IRabbitMqConnectionFactory } from './connectionFactory';
|
|
3
|
+
import { IQueueNameConfig } from './common';
|
|
4
|
+
import { Logger } from './childLogger';
|
|
6
5
|
export declare class RabbitMqProducer {
|
|
7
6
|
private logger;
|
|
8
7
|
private connectionFactory;
|
|
9
8
|
constructor(logger: Logger, connectionFactory: IRabbitMqConnectionFactory);
|
|
10
9
|
publish<T>(queue: string | IQueueNameConfig, message: T, options?: IQueueNameConfig): Promise<void>;
|
|
11
|
-
protected getMessageBuffer<T>(message: T): Buffer
|
|
12
|
-
protected getQueueSettings(deadletterExchangeName: string):
|
|
10
|
+
protected getMessageBuffer<T>(message: T): Buffer<ArrayBuffer>;
|
|
11
|
+
protected getQueueSettings(deadletterExchangeName: string): Options.AssertQueue;
|
|
13
12
|
}
|
package/dist/producer.js
CHANGED
|
@@ -16,7 +16,7 @@ class RabbitMqProducer {
|
|
|
16
16
|
constructor(logger, connectionFactory) {
|
|
17
17
|
this.logger = logger;
|
|
18
18
|
this.connectionFactory = connectionFactory;
|
|
19
|
-
this.logger = (0, childLogger_1.createChildLogger)(logger,
|
|
19
|
+
this.logger = (0, childLogger_1.createChildLogger)(logger, 'RabbitMqProducer');
|
|
20
20
|
}
|
|
21
21
|
publish(queue, message, options) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -32,21 +32,21 @@ class RabbitMqProducer {
|
|
|
32
32
|
persistent: true,
|
|
33
33
|
})) {
|
|
34
34
|
this.logger.error("unable to send message to queue '%j' {%j}", queueConfig, message);
|
|
35
|
-
throw new Error(
|
|
35
|
+
throw new Error('Unable to send message');
|
|
36
36
|
}
|
|
37
37
|
this.logger.trace("message sent to queue '%s' (%j)", queueConfig.name, message);
|
|
38
38
|
return channel.close();
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
getMessageBuffer(message) {
|
|
42
|
-
return Buffer.from(JSON.stringify(message),
|
|
42
|
+
return Buffer.from(JSON.stringify(message), 'utf8');
|
|
43
43
|
}
|
|
44
44
|
getQueueSettings(deadletterExchangeName) {
|
|
45
45
|
return {
|
|
46
46
|
durable: true,
|
|
47
47
|
autoDelete: true,
|
|
48
48
|
arguments: {
|
|
49
|
-
|
|
49
|
+
'x-dead-letter-exchange': deadletterExchangeName,
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
}
|
package/dist/publisher.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Logger } from "./childLogger";
|
|
1
|
+
import { Channel, Options } from 'amqplib';
|
|
2
|
+
import { IRabbitMqConnectionFactory } from './connectionFactory';
|
|
3
|
+
import { IQueueNameConfig } from './common';
|
|
4
|
+
import { Logger } from './childLogger';
|
|
6
5
|
export declare class RabbitMqPublisher {
|
|
7
6
|
private logger;
|
|
8
7
|
private connectionFactory;
|
|
9
8
|
constructor(logger: Logger, connectionFactory: IRabbitMqConnectionFactory);
|
|
10
9
|
publish<T>(queue: string | IQueueNameConfig, message: T, options?: IQueueNameConfig): Promise<void>;
|
|
11
10
|
private setupChannel;
|
|
12
|
-
protected getMessageBuffer<T>(message: T): Buffer
|
|
13
|
-
protected getChannelSetup(channel:
|
|
14
|
-
protected getSettings():
|
|
11
|
+
protected getMessageBuffer<T>(message: T): Buffer<ArrayBuffer>;
|
|
12
|
+
protected getChannelSetup(channel: Channel, queueConfig: IQueueNameConfig): Promise<import("amqplib").Replies.AssertExchange>[];
|
|
13
|
+
protected getSettings(): Options.AssertQueue;
|
|
15
14
|
}
|
package/dist/publisher.js
CHANGED
|
@@ -16,7 +16,7 @@ class RabbitMqPublisher {
|
|
|
16
16
|
constructor(logger, connectionFactory) {
|
|
17
17
|
this.logger = logger;
|
|
18
18
|
this.connectionFactory = connectionFactory;
|
|
19
|
-
this.logger = (0, childLogger_1.createChildLogger)(logger,
|
|
19
|
+
this.logger = (0, childLogger_1.createChildLogger)(logger, 'RabbitMqPublisher');
|
|
20
20
|
}
|
|
21
21
|
publish(queue, message, options) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -28,13 +28,13 @@ class RabbitMqPublisher {
|
|
|
28
28
|
channel.prefetch(options.prefetch, options.globalPrefetch);
|
|
29
29
|
}
|
|
30
30
|
yield this.setupChannel(channel, queueConfig);
|
|
31
|
-
channel.publish(queueConfig.dlx,
|
|
31
|
+
channel.publish(queueConfig.dlx, '', this.getMessageBuffer(message));
|
|
32
32
|
this.logger.trace("message sent to exchange '%s' (%j)", queueConfig.dlx, message);
|
|
33
33
|
return channel.close();
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
36
|
this.logger.error("unable to send message to exchange '%j' {%j}", queueConfig.dlx, message);
|
|
37
|
-
throw new Error(
|
|
37
|
+
throw new Error('Unable to send message');
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -43,12 +43,10 @@ class RabbitMqPublisher {
|
|
|
43
43
|
return Promise.all(this.getChannelSetup(channel, queueConfig));
|
|
44
44
|
}
|
|
45
45
|
getMessageBuffer(message) {
|
|
46
|
-
return Buffer.from(JSON.stringify(message),
|
|
46
|
+
return Buffer.from(JSON.stringify(message), 'utf8');
|
|
47
47
|
}
|
|
48
48
|
getChannelSetup(channel, queueConfig) {
|
|
49
|
-
return [
|
|
50
|
-
channel.assertExchange(queueConfig.dlx, "fanout", this.getSettings()),
|
|
51
|
-
];
|
|
49
|
+
return [channel.assertExchange(queueConfig.dlx, 'fanout', this.getSettings())];
|
|
52
50
|
}
|
|
53
51
|
getSettings() {
|
|
54
52
|
return {
|
package/dist/subscriber.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Channel, Message, Options } from "amqplib";
|
|
2
2
|
import { IRabbitMqConnectionFactory } from "./connectionFactory";
|
|
3
3
|
import { IQueueNameConfig } from "./common";
|
|
4
4
|
import { Logger } from "./childLogger";
|
|
@@ -12,8 +12,8 @@ export declare class RabbitMqSubscriber {
|
|
|
12
12
|
subscribe<T>(queue: string | IQueueNameConfig, action: (message: T) => Promise<IRabbitMqSubscriberDisposer>, options?: Partial<IQueueNameConfig>): Promise<IRabbitMqSubscriberDisposer>;
|
|
13
13
|
private setupChannel;
|
|
14
14
|
private subscribeToChannel;
|
|
15
|
-
protected getMessageObject<T>(message:
|
|
16
|
-
protected getChannelSetup(channel:
|
|
17
|
-
protected getQueueSettings():
|
|
18
|
-
protected getDLSettings():
|
|
15
|
+
protected getMessageObject<T>(message: Message): T;
|
|
16
|
+
protected getChannelSetup(channel: Channel, queueConfig: IQueueNameConfig): Promise<string>;
|
|
17
|
+
protected getQueueSettings(): Options.AssertQueue;
|
|
18
|
+
protected getDLSettings(): Options.AssertQueue;
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/rabbitmq-pubsub",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.191-nightly.0",
|
|
4
4
|
"description": "A graphql-subscriptions PubSub Engine using RabbitMQ",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"lint": "tslint ./src/**/*.ts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"amqplib": "^0.
|
|
27
|
+
"amqplib": "^0.10.9"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/amqplib": "^0.
|
|
31
|
-
"@types/node": "^
|
|
30
|
+
"@types/amqplib": "^0.10.8",
|
|
31
|
+
"@types/node": "^25.0.3",
|
|
32
32
|
"tslint": "^5.20.1",
|
|
33
|
-
"typescript": "^
|
|
33
|
+
"typescript": "^5.9.3"
|
|
34
34
|
},
|
|
35
35
|
"typings": "dist/index.d.ts",
|
|
36
36
|
"typescript": {
|