node-server-engine 1.12.1 → 1.12.3
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/.nycrc
CHANGED
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { Attributes } from '@google-cloud/pubsub';
|
|
2
2
|
import { PubSubAddSubscriberOptions, PubSubMessageHandler, PubSubPublisherOptions } from './PubSub.types';
|
|
3
|
-
/**
|
|
4
|
-
* This is a singleton service who's role is to manage pub/sub connections
|
|
5
|
-
* It is the preferred way to interact with Pub/Sub as it manages the underlying subscription and handler objects
|
|
6
|
-
* It avoids potential subscription splitting on an instance
|
|
7
|
-
*/
|
|
8
3
|
export declare const PubSub: {
|
|
9
4
|
/**
|
|
10
|
-
*
|
|
5
|
+
* ✅ FAST + NON-BLOCKING INIT
|
|
11
6
|
*/
|
|
12
7
|
init(): Promise<void>;
|
|
13
8
|
/**
|
|
14
|
-
* Shutdown
|
|
9
|
+
* Shutdown
|
|
15
10
|
*/
|
|
16
11
|
shutdown(): Promise<void>;
|
|
17
12
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param topic - Topic name or array of topic names
|
|
20
|
-
* @param options - Publisher configuration options
|
|
13
|
+
* Publisher registration
|
|
21
14
|
*/
|
|
22
15
|
addPublisher(topic: string | Array<string>, options?: PubSubPublisherOptions): void;
|
|
23
16
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param subscription - Name of the Pub/Sub subscription
|
|
26
|
-
* @param handler - Function or list of functions to set as message handlers
|
|
27
|
-
* @param options - Indicates that the additional options need to handle on Subscriber
|
|
17
|
+
* Subscriber registration
|
|
28
18
|
*/
|
|
29
|
-
addSubscriber<T>(
|
|
19
|
+
addSubscriber<T>(subscriptionName: string, handler: PubSubMessageHandler<T> | Array<PubSubMessageHandler<T>>, options?: PubSubAddSubscriberOptions): void;
|
|
30
20
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @param topic - Name of the topic
|
|
33
|
-
* @param message - Content of the message, must be an object that can be JSON stringified
|
|
34
|
-
* @param attributes - Attributes for this message, can be used to filter messages on the subscription
|
|
35
|
-
* @param orderingKey - Enforce order guarantee of messages sent with the same key
|
|
21
|
+
* ✅ SAFE PUBLISH (with retry)
|
|
36
22
|
*/
|
|
37
23
|
publish(topic: string, message: unknown, attributes?: Attributes, orderingKey?: string): Promise<void>;
|
|
38
24
|
};
|
|
@@ -10,91 +10,108 @@ var _EngineError = require("../EngineError");
|
|
|
10
10
|
var _LifecycleController = require("../LifecycleController");
|
|
11
11
|
var _utils = require("../../utils");
|
|
12
12
|
const namespace = 'engine:PubSub';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Associative containing all the subscriptions sorted by topic registered for publishing
|
|
16
|
-
*/
|
|
17
13
|
const subscriptions = {};
|
|
14
|
+
const topics = {};
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
|
-
*
|
|
17
|
+
* Add basic retry wrapper
|
|
21
18
|
*/
|
|
22
|
-
const
|
|
23
|
-
|
|
19
|
+
const withRetry = async (fn, retries = 3, delay = 500) => {
|
|
20
|
+
let lastError;
|
|
21
|
+
for (let i = 0; i < retries; i++) {
|
|
22
|
+
try {
|
|
23
|
+
return await fn();
|
|
24
|
+
} catch (err) {
|
|
25
|
+
lastError = err;
|
|
26
|
+
await new Promise(res => setTimeout(res, delay * (i + 1)));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw lastError;
|
|
30
|
+
};
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
27
|
-
* It is the preferred way to interact with Pub/Sub as it manages the underlying subscription and handler objects
|
|
28
|
-
* It avoids potential subscription splitting on an instance
|
|
33
|
+
* PubSub client with safer defaults
|
|
29
34
|
*/
|
|
35
|
+
const pubSubClient = new _pubsub.PubSub({
|
|
36
|
+
apiEndpoint: 'pubsub.googleapis.com'
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** Re-open a subscription's message stream after a transient error */
|
|
40
|
+
function reattachSubscription(subscriptionName, delayMs = 5000) {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
const entry = subscriptions[subscriptionName];
|
|
43
|
+
if (!entry) return;
|
|
44
|
+
const {
|
|
45
|
+
subscription,
|
|
46
|
+
handlers,
|
|
47
|
+
isDebezium
|
|
48
|
+
} = entry;
|
|
49
|
+
(0, _utils.reportDebug)({
|
|
50
|
+
namespace,
|
|
51
|
+
message: `Reattaching subscription '${subscriptionName}'`
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Remove all existing listeners before re-adding to avoid duplicates
|
|
55
|
+
subscription.removeAllListeners('message');
|
|
56
|
+
subscription.removeAllListeners('error');
|
|
57
|
+
subscription.on('message', message => {
|
|
58
|
+
(0, _handleMessage.handleMessage)(message, subscription, handlers, isDebezium).catch(_utils.reportError);
|
|
59
|
+
});
|
|
60
|
+
subscription.on('error', error => {
|
|
61
|
+
(0, _utils.reportError)(error);
|
|
62
|
+
// Reconnect on transient errors (DEADLINE_EXCEEDED, UNAVAILABLE, INTERNAL)
|
|
63
|
+
const code = error?.code;
|
|
64
|
+
if (code === 4 || code === 14 || code === 13) {
|
|
65
|
+
reattachSubscription(subscriptionName, Math.min(delayMs * 2, 60000));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}, delayMs);
|
|
69
|
+
}
|
|
30
70
|
const PubSub = exports.PubSub = {
|
|
31
71
|
/**
|
|
32
|
-
*
|
|
72
|
+
* ✅ FAST + NON-BLOCKING INIT
|
|
33
73
|
*/
|
|
34
74
|
async init() {
|
|
35
75
|
(0, _utils.reportDebug)({
|
|
36
76
|
namespace,
|
|
37
|
-
message: `Initializing Pub/Sub`
|
|
77
|
+
message: `Initializing Pub/Sub (safe mode)`
|
|
38
78
|
});
|
|
39
|
-
|
|
40
|
-
await Promise.all([
|
|
41
|
-
// Test that all topics actually exist and that we have permissions
|
|
42
|
-
...Object.values(topics).map(async topic => {
|
|
43
|
-
const [exists] = await topic.exists();
|
|
44
|
-
if (!exists) throw new _EngineError.EngineError(`Topic ${topic.name} does not exist`);
|
|
45
|
-
// Test permission ton publish to topic
|
|
46
|
-
const [permissions] = await topic.iam.testPermissions(['pubsub.topics.publish']);
|
|
47
|
-
const hasPermissions = Object.values(permissions).every(success => success);
|
|
48
|
-
if (!hasPermissions) throw new _EngineError.EngineError(`Instance does not have appropriate permissions to publish to topic ${topic.name}`);
|
|
49
|
-
}),
|
|
50
|
-
// Test that all subscriptions actually exist and that we have permissions
|
|
51
|
-
...Object.values(subscriptions).map(async ({
|
|
52
|
-
subscription
|
|
53
|
-
}) => {
|
|
54
|
-
const [exists] = await subscription.exists();
|
|
55
|
-
if (!exists) throw new _EngineError.EngineError(`Subscription ${subscription.name} does not exist`);
|
|
56
|
-
// Test permission ton consume subscription
|
|
57
|
-
const [permissions] = await subscription.iam.testPermissions(['pubsub.subscriptions.consume']);
|
|
58
|
-
const hasPermissions = Object.values(permissions).every(success => success);
|
|
59
|
-
if (!hasPermissions) throw new _EngineError.EngineError(`Instance does not have appropriate permissions to subscribe to subscription ${subscription.name}`);
|
|
60
|
-
})]);
|
|
61
|
-
|
|
62
|
-
// Register handlers on the subscriptions to activate them
|
|
63
|
-
for (const {
|
|
79
|
+
for (const [subscriptionName, {
|
|
64
80
|
subscription,
|
|
65
81
|
handlers,
|
|
66
82
|
isDebezium
|
|
67
|
-
} of Object.
|
|
83
|
+
}] of Object.entries(subscriptions)) {
|
|
68
84
|
subscription.on('message', message => {
|
|
69
|
-
(0, _handleMessage.handleMessage)(message, subscription, handlers, isDebezium).catch(
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
(0, _handleMessage.handleMessage)(message, subscription, handlers, isDebezium).catch(_utils.reportError);
|
|
86
|
+
});
|
|
87
|
+
subscription.on('error', error => {
|
|
88
|
+
(0, _utils.reportError)(error);
|
|
89
|
+
// Auto-reconnect on transient gRPC errors (DEADLINE_EXCEEDED=4, UNAVAILABLE=14, INTERNAL=13)
|
|
90
|
+
const code = error?.code;
|
|
91
|
+
if (code === 4 || code === 14 || code === 13) {
|
|
92
|
+
reattachSubscription(subscriptionName, 5000);
|
|
93
|
+
}
|
|
72
94
|
});
|
|
73
95
|
}
|
|
74
96
|
_LifecycleController.LifecycleController.register(PubSub);
|
|
75
97
|
},
|
|
76
98
|
/**
|
|
77
|
-
* Shutdown
|
|
99
|
+
* Shutdown
|
|
78
100
|
*/
|
|
79
101
|
async shutdown() {
|
|
80
102
|
(0, _utils.reportDebug)({
|
|
81
103
|
namespace,
|
|
82
104
|
message: `Shutting down Pub/Sub`
|
|
83
105
|
});
|
|
84
|
-
// Flush all pending messages and shut down connections
|
|
85
106
|
await Promise.all([...Object.values(topics).map(async topic => topic.flush()), ...Object.values(subscriptions).map(async ({
|
|
86
107
|
subscription
|
|
87
108
|
}) => subscription.close())]);
|
|
88
|
-
// Delete the stored topics/subscriptions
|
|
89
109
|
Object.keys(topics).forEach(topic => delete topics[topic]);
|
|
90
110
|
Object.keys(subscriptions).forEach(subscription => delete subscriptions[subscription]);
|
|
91
|
-
// Close the client
|
|
92
111
|
await pubSubClient.close();
|
|
93
112
|
},
|
|
94
113
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param topic - Topic name or array of topic names
|
|
97
|
-
* @param options - Publisher configuration options
|
|
114
|
+
* Publisher registration
|
|
98
115
|
*/
|
|
99
116
|
addPublisher(topic, options) {
|
|
100
117
|
const topicArray = topic instanceof Array ? topic : [topic];
|
|
@@ -103,104 +120,68 @@ const PubSub = exports.PubSub = {
|
|
|
103
120
|
message: `Registering publisher for topics '${topicArray.join("', '")}'`,
|
|
104
121
|
data: options
|
|
105
122
|
});
|
|
106
|
-
// Register a new topic if it does not exist yet
|
|
107
123
|
for (const topic of topicArray) {
|
|
108
|
-
if (!
|
|
124
|
+
if (!topics[topic]) {
|
|
109
125
|
topics[topic] = pubSubClient.topic(topic, {
|
|
110
126
|
enableOpenTelemetryTracing: true,
|
|
111
127
|
messageOrdering: options?.enableMessageOrdering ?? false,
|
|
112
128
|
batching: options?.batching ? {
|
|
113
129
|
maxMessages: options.batching.maxMessages ?? 100,
|
|
114
130
|
maxBytes: options.batching.maxBytes ?? 1024 * 1024,
|
|
115
|
-
// 1MB
|
|
116
131
|
maxMilliseconds: options.batching.maxMilliseconds ?? 100
|
|
117
|
-
} : undefined,
|
|
118
|
-
gaxOpts: options?.retry ? {
|
|
119
|
-
retry: {
|
|
120
|
-
retryCodes: [10, 14],
|
|
121
|
-
// ABORTED, UNAVAILABLE
|
|
122
|
-
backoffSettings: {
|
|
123
|
-
initialRetryDelayMillis: options.retry.initialDelayMillis ?? 100,
|
|
124
|
-
maxRetryDelayMillis: options.retry.maxDelayMillis ?? 60000,
|
|
125
|
-
retryDelayMultiplier: options.retry.delayMultiplier ?? 1.3,
|
|
126
|
-
initialRpcTimeoutMillis: 60000,
|
|
127
|
-
maxRpcTimeoutMillis: 600000,
|
|
128
|
-
rpcTimeoutMultiplier: 1.0,
|
|
129
|
-
totalTimeoutMillis: 600000
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
132
|
} : undefined
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
139
|
-
* @param subscription - Name of the Pub/Sub subscription
|
|
140
|
-
* @param handler - Function or list of functions to set as message handlers
|
|
141
|
-
* @param options - Indicates that the additional options need to handle on Subscriber
|
|
138
|
+
* Subscriber registration
|
|
142
139
|
*/
|
|
143
|
-
addSubscriber(
|
|
140
|
+
addSubscriber(subscriptionName, handler, options = {}) {
|
|
144
141
|
const handlers = handler instanceof Array ? handler : [handler];
|
|
145
|
-
const isDebezium = options?.isDebezium ?? false;
|
|
146
|
-
const first = options?.first ?? false;
|
|
147
|
-
const flowControl = options?.flowControl;
|
|
148
|
-
const ackDeadline = options?.ackDeadline;
|
|
149
142
|
(0, _utils.reportDebug)({
|
|
150
143
|
namespace,
|
|
151
|
-
message: `Registering subscriber
|
|
152
|
-
data:
|
|
153
|
-
first,
|
|
154
|
-
handlersCount: handlers.length,
|
|
155
|
-
isDebezium,
|
|
156
|
-
flowControl
|
|
157
|
-
}
|
|
144
|
+
message: `Registering subscriber '${subscriptionName}'`,
|
|
145
|
+
data: options
|
|
158
146
|
});
|
|
159
|
-
if (!
|
|
160
|
-
subscriptions[
|
|
161
|
-
subscription: pubSubClient.subscription(
|
|
147
|
+
if (!subscriptions[subscriptionName]) {
|
|
148
|
+
subscriptions[subscriptionName] = {
|
|
149
|
+
subscription: pubSubClient.subscription(subscriptionName, {
|
|
162
150
|
enableOpenTelemetryTracing: true,
|
|
163
|
-
flowControl: flowControl
|
|
164
|
-
maxMessages: flowControl.maxMessages ?? 1000,
|
|
165
|
-
maxBytes: flowControl.maxBytes ?? 100 * 1024 * 1024,
|
|
166
|
-
// 100MB
|
|
167
|
-
allowExcessMessages: flowControl.allowExcessMessages ?? true
|
|
168
|
-
} : {
|
|
151
|
+
flowControl: options.flowControl ?? {
|
|
169
152
|
maxMessages: 1000,
|
|
170
153
|
maxBytes: 100 * 1024 * 1024,
|
|
171
154
|
allowExcessMessages: true
|
|
172
155
|
},
|
|
173
|
-
ackDeadline: ackDeadline ?? 60
|
|
156
|
+
ackDeadline: options.ackDeadline ?? 60
|
|
174
157
|
}),
|
|
175
|
-
handlers: []
|
|
158
|
+
handlers: [],
|
|
159
|
+
isDebezium: options?.isDebezium ?? false
|
|
176
160
|
};
|
|
177
161
|
}
|
|
178
|
-
if (
|
|
179
|
-
if (first) subscriptions[subscription].handlers.push(...handlers);else subscriptions[subscription].handlers.unshift(...handlers);
|
|
162
|
+
if (options.first) subscriptions[subscriptionName].handlers.push(...handlers);else subscriptions[subscriptionName].handlers.unshift(...handlers);
|
|
180
163
|
},
|
|
181
164
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @param topic - Name of the topic
|
|
184
|
-
* @param message - Content of the message, must be an object that can be JSON stringified
|
|
185
|
-
* @param attributes - Attributes for this message, can be used to filter messages on the subscription
|
|
186
|
-
* @param orderingKey - Enforce order guarantee of messages sent with the same key
|
|
165
|
+
* ✅ SAFE PUBLISH (with retry)
|
|
187
166
|
*/
|
|
188
167
|
async publish(topic, message, attributes, orderingKey) {
|
|
189
|
-
if (!topics[topic])
|
|
168
|
+
if (!topics[topic]) {
|
|
169
|
+
throw new _EngineError.EngineError(`No publisher registered for topic '${topic}'`);
|
|
170
|
+
}
|
|
190
171
|
(0, _utils.reportDebug)({
|
|
191
172
|
namespace,
|
|
192
|
-
message: `
|
|
173
|
+
message: `Publishing to '${topic}'`,
|
|
193
174
|
data: {
|
|
194
175
|
message,
|
|
195
176
|
attributes,
|
|
196
177
|
orderingKey
|
|
197
178
|
}
|
|
198
179
|
});
|
|
199
|
-
await topics[topic].publishMessage({
|
|
180
|
+
await withRetry(() => topics[topic].publishMessage({
|
|
200
181
|
json: message,
|
|
201
182
|
attributes,
|
|
202
183
|
orderingKey
|
|
203
|
-
});
|
|
184
|
+
}));
|
|
204
185
|
}
|
|
205
186
|
};
|
|
206
187
|
//# sourceMappingURL=PubSub.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSub.js","names":["_pubsub","require","_handleMessage","_EngineError","_LifecycleController","_utils","namespace","subscriptions","topics","pubSubClient","PubsubClient","PubSub","exports","init","reportDebug","message","Promise","all","Object","values","map","topic","exists","EngineError","name","permissions","iam","testPermissions","hasPermissions","every","success","subscription","handlers","isDebezium","on","handleMessage","catch","error","reportError","LifecycleController","register","shutdown","flush","close","keys","forEach","addPublisher","options","topicArray","Array","join","data","includes","enableOpenTelemetryTracing","messageOrdering","enableMessageOrdering","batching","maxMessages","maxBytes","maxMilliseconds","undefined","gaxOpts","retry","retryCodes","backoffSettings","initialRetryDelayMillis","initialDelayMillis","maxRetryDelayMillis","maxDelayMillis","retryDelayMultiplier","delayMultiplier","initialRpcTimeoutMillis","maxRpcTimeoutMillis","rpcTimeoutMultiplier","totalTimeoutMillis","addSubscriber","handler","first","flowControl","ackDeadline","handlersCount","length","allowExcessMessages","push","unshift","publish","attributes","orderingKey","publishMessage","json"],"sources":["../../../src/entities/PubSub/PubSub.ts"],"sourcesContent":["import {\n Attributes,\n PubSub as PubsubClient,\n Message\n} from '@google-cloud/pubsub';\nimport { handleMessage } from './handleMessage';\nimport {\n PubSubTopicsMap,\n PubSubSubscriptionsMap,\n PubSubAddSubscriberOptions,\n PubSubMessageHandler,\n PubSubPublisherOptions\n} from './PubSub.types';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { reportDebug, reportError } from 'utils';\n\nconst namespace = 'engine:PubSub';\n\n/**\n * Associative containing all the subscriptions sorted by topic registered for publishing\n */\nconst subscriptions: PubSubSubscriptionsMap = {};\n\n/**\n * Associative containing all the topics registered for publishing\n */\nconst topics: PubSubTopicsMap = {};\n\nconst pubSubClient = new PubsubClient();\n\n/**\n * This is a singleton service who's role is to manage pub/sub connections\n * It is the preferred way to interact with Pub/Sub as it manages the underlying subscription and handler objects\n * It avoids potential subscription splitting on an instance\n */\nexport const PubSub = {\n /**\n * Initialize the registered publishers and subscribers\n */\n async init(): Promise<void> {\n reportDebug({ namespace, message: `Initializing Pub/Sub` });\n // Check that all topics/permissions exist, and that we have permission on them\n await Promise.all([\n // Test that all topics actually exist and that we have permissions\n ...Object.values(topics).map(async (topic) => {\n const [exists] = await topic.exists();\n if (!exists)\n throw new EngineError(`Topic ${topic.name} does not exist`);\n // Test permission ton publish to topic\n const [permissions] = await topic.iam.testPermissions([\n 'pubsub.topics.publish'\n ]);\n const hasPermissions = Object.values(permissions).every(\n (success) => success\n );\n if (!hasPermissions)\n throw new EngineError(\n `Instance does not have appropriate permissions to publish to topic ${topic.name}`\n );\n }),\n // Test that all subscriptions actually exist and that we have permissions\n ...Object.values(subscriptions).map(async ({ subscription }) => {\n const [exists] = await subscription.exists();\n if (!exists)\n throw new EngineError(\n `Subscription ${subscription.name} does not exist`\n );\n // Test permission ton consume subscription\n const [permissions] = await subscription.iam.testPermissions([\n 'pubsub.subscriptions.consume'\n ]);\n const hasPermissions = Object.values(permissions).every(\n (success) => success\n );\n if (!hasPermissions)\n throw new EngineError(\n `Instance does not have appropriate permissions to subscribe to subscription ${subscription.name}`\n );\n })\n ]);\n\n // Register handlers on the subscriptions to activate them\n for (const { subscription, handlers, isDebezium } of Object.values(\n subscriptions\n )) {\n subscription.on('message', (message) => {\n handleMessage(\n message as Message,\n subscription,\n handlers,\n isDebezium\n ).catch((error) => {\n reportError(error);\n });\n });\n }\n\n LifecycleController.register(PubSub);\n },\n\n /**\n * Shutdown the registered publishers and subscribers\n */\n async shutdown(): Promise<void> {\n reportDebug({ namespace, message: `Shutting down Pub/Sub` });\n // Flush all pending messages and shut down connections\n await Promise.all([\n ...Object.values(topics).map(async (topic) => topic.flush()),\n ...Object.values(subscriptions).map(async ({ subscription }) =>\n subscription.close()\n )\n ]);\n // Delete the stored topics/subscriptions\n Object.keys(topics).forEach((topic) => delete topics[topic]);\n Object.keys(subscriptions).forEach(\n (subscription) => delete subscriptions[subscription]\n );\n // Close the client\n await pubSubClient.close();\n },\n\n /**\n * Creates a publisher if it does not exist yet\n * @param topic - Topic name or array of topic names\n * @param options - Publisher configuration options\n */\n addPublisher(\n topic: string | Array<string>,\n options?: PubSubPublisherOptions\n ): void {\n const topicArray = topic instanceof Array ? topic : [topic];\n reportDebug({\n namespace,\n message: `Registering publisher for topics '${topicArray.join(\"', '\")}'`,\n data: options\n });\n // Register a new topic if it does not exist yet\n for (const topic of topicArray) {\n if (!Object.keys(topics).includes(topic)) {\n topics[topic] = pubSubClient.topic(topic, {\n enableOpenTelemetryTracing: true,\n messageOrdering: options?.enableMessageOrdering ?? false,\n batching: options?.batching\n ? {\n maxMessages: options.batching.maxMessages ?? 100,\n maxBytes: options.batching.maxBytes ?? 1024 * 1024, // 1MB\n maxMilliseconds: options.batching.maxMilliseconds ?? 100\n }\n : undefined,\n gaxOpts: options?.retry\n ? {\n retry: {\n retryCodes: [10, 14], // ABORTED, UNAVAILABLE\n backoffSettings: {\n initialRetryDelayMillis:\n options.retry.initialDelayMillis ?? 100,\n maxRetryDelayMillis: options.retry.maxDelayMillis ?? 60000,\n retryDelayMultiplier: options.retry.delayMultiplier ?? 1.3,\n initialRpcTimeoutMillis: 60000,\n maxRpcTimeoutMillis: 600000,\n rpcTimeoutMultiplier: 1.0,\n totalTimeoutMillis: 600000\n }\n }\n }\n : undefined\n });\n }\n }\n },\n\n /**\n * Add message handlers to a subscription\n * @param subscription - Name of the Pub/Sub subscription\n * @param handler - Function or list of functions to set as message handlers\n * @param options - Indicates that the additional options need to handle on Subscriber\n */\n addSubscriber<T>(\n subscription: string,\n handler: PubSubMessageHandler<T> | Array<PubSubMessageHandler<T>>,\n options: PubSubAddSubscriberOptions = {}\n ): void {\n const handlers = handler instanceof Array ? handler : [handler];\n const isDebezium = options?.isDebezium ?? false;\n const first = options?.first ?? false;\n const flowControl = options?.flowControl;\n const ackDeadline = options?.ackDeadline;\n\n reportDebug({\n namespace,\n message: `Registering subscriber for subscription '${subscription}'`,\n data: {\n first,\n handlersCount: handlers.length,\n isDebezium,\n flowControl\n }\n });\n if (!Object.keys(subscriptions).includes(subscription)) {\n subscriptions[subscription] = {\n subscription: pubSubClient.subscription(subscription, {\n enableOpenTelemetryTracing: true,\n flowControl: flowControl\n ? {\n maxMessages: flowControl.maxMessages ?? 1000,\n maxBytes: flowControl.maxBytes ?? 100 * 1024 * 1024, // 100MB\n allowExcessMessages: flowControl.allowExcessMessages ?? true\n }\n : {\n maxMessages: 1000,\n maxBytes: 100 * 1024 * 1024,\n allowExcessMessages: true\n },\n ackDeadline: ackDeadline ?? 60\n }),\n handlers: []\n };\n }\n\n if (isDebezium) subscriptions[subscription].isDebezium = true;\n\n if (first) subscriptions[subscription].handlers.push(...handlers);\n else subscriptions[subscription].handlers.unshift(...handlers);\n },\n\n /**\n * Send a message to a Pub/Sub topic\n * @param topic - Name of the topic\n * @param message - Content of the message, must be an object that can be JSON stringified\n * @param attributes - Attributes for this message, can be used to filter messages on the subscription\n * @param orderingKey - Enforce order guarantee of messages sent with the same key\n */\n async publish(\n topic: string,\n message: unknown,\n attributes?: Attributes,\n orderingKey?: string\n ): Promise<void> {\n if (!topics[topic])\n throw new EngineError(`No publisher was registered for topic '${topic}'`);\n reportDebug({\n namespace,\n message: `Sending message to topic '${topic}'`,\n data: { message, attributes, orderingKey }\n });\n await topics[topic].publishMessage({\n json: message,\n attributes,\n orderingKey\n });\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,cAAA,GAAAD,OAAA;AAQA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,GAAG,eAAe;;AAEjC;AACA;AACA;AACA,MAAMC,aAAqC,GAAG,CAAC,CAAC;;AAEhD;AACA;AACA;AACA,MAAMC,MAAuB,GAAG,CAAC,CAAC;AAElC,MAAMC,YAAY,GAAG,IAAIC,cAAY,CAAC,CAAC;;AAEvC;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACpB;AACF;AACA;EACE,MAAME,IAAIA,CAAA,EAAkB;IAC1B,IAAAC,kBAAW,EAAC;MAAER,SAAS;MAAES,OAAO,EAAE;IAAuB,CAAC,CAAC;IAC3D;IACA,MAAMC,OAAO,CAACC,GAAG,CAAC;IAChB;IACA,GAAGC,MAAM,CAACC,MAAM,CAACX,MAAM,CAAC,CAACY,GAAG,CAAC,MAAOC,KAAK,IAAK;MAC5C,MAAM,CAACC,MAAM,CAAC,GAAG,MAAMD,KAAK,CAACC,MAAM,CAAC,CAAC;MACrC,IAAI,CAACA,MAAM,EACT,MAAM,IAAIC,wBAAW,CAAC,SAASF,KAAK,CAACG,IAAI,iBAAiB,CAAC;MAC7D;MACA,MAAM,CAACC,WAAW,CAAC,GAAG,MAAMJ,KAAK,C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AACmD,IAAI,CAAC,GAAGnD,QAAQ,CAAC,CAAC,KAC7DzB,aAAa,CAACwB,YAAY,CAAC,CAACC,QAAQ,CAACoD,OAAO,CAAC,GAAGpD,QAAQ,CAAC;EAChE,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMqD,OAAOA,CACXhE,KAAa,EACbN,OAAgB,EAChBuE,UAAuB,EACvBC,WAAoB,EACL;IACf,IAAI,CAAC/E,MAAM,CAACa,KAAK,CAAC,EAChB,MAAM,IAAIE,wBAAW,CAAC,0CAA0CF,KAAK,GAAG,CAAC;IAC3E,IAAAP,kBAAW,EAAC;MACVR,SAAS;MACTS,OAAO,EAAE,6BAA6BM,KAAK,GAAG;MAC9C8B,IAAI,EAAE;QAAEpC,OAAO;QAAEuE,UAAU;QAAEC;MAAY;IAC3C,CAAC,CAAC;IACF,MAAM/E,MAAM,CAACa,KAAK,CAAC,CAACmE,cAAc,CAAC;MACjCC,IAAI,EAAE1E,OAAO;MACbuE,UAAU;MACVC;IACF,CAAC,CAAC;EACJ;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PubSub.js","names":["_pubsub","require","_handleMessage","_EngineError","_LifecycleController","_utils","namespace","subscriptions","topics","withRetry","fn","retries","delay","lastError","i","err","Promise","res","setTimeout","pubSubClient","PubsubClient","apiEndpoint","reattachSubscription","subscriptionName","delayMs","entry","subscription","handlers","isDebezium","reportDebug","message","removeAllListeners","on","handleMessage","catch","reportError","error","code","Math","min","PubSub","exports","init","Object","entries","LifecycleController","register","shutdown","all","values","map","topic","flush","close","keys","forEach","addPublisher","options","topicArray","Array","join","data","enableOpenTelemetryTracing","messageOrdering","enableMessageOrdering","batching","maxMessages","maxBytes","maxMilliseconds","undefined","addSubscriber","handler","flowControl","allowExcessMessages","ackDeadline","first","push","unshift","publish","attributes","orderingKey","EngineError","publishMessage","json"],"sources":["../../../src/entities/PubSub/PubSub.ts"],"sourcesContent":["import {\n Attributes,\n PubSub as PubsubClient,\n Message\n} from '@google-cloud/pubsub';\nimport { handleMessage } from './handleMessage';\nimport {\n PubSubTopicsMap,\n PubSubSubscriptionsMap,\n PubSubAddSubscriberOptions,\n PubSubMessageHandler,\n PubSubPublisherOptions\n} from './PubSub.types';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { reportDebug, reportError } from 'utils';\n\nconst namespace = 'engine:PubSub';\n\nconst subscriptions: PubSubSubscriptionsMap = {};\nconst topics: PubSubTopicsMap = {};\n\n/**\n * Add basic retry wrapper\n */\nconst withRetry = async <T>(\n fn: () => Promise<T>,\n retries = 3,\n delay = 500\n): Promise<T> => {\n let lastError: any;\n for (let i = 0; i < retries; i++) {\n try {\n return await fn();\n } catch (err) {\n lastError = err;\n await new Promise((res) => setTimeout(res, delay * (i + 1)));\n }\n }\n throw lastError;\n};\n\n/**\n * PubSub client with safer defaults\n */\nconst pubSubClient = new PubsubClient({\n apiEndpoint: 'pubsub.googleapis.com'\n});\n\n/** Re-open a subscription's message stream after a transient error */\nfunction reattachSubscription(subscriptionName: string, delayMs = 5000): void {\n setTimeout(() => {\n const entry = subscriptions[subscriptionName];\n if (!entry) return;\n const { subscription, handlers, isDebezium } = entry;\n\n reportDebug({ namespace, message: `Reattaching subscription '${subscriptionName}'` });\n\n // Remove all existing listeners before re-adding to avoid duplicates\n subscription.removeAllListeners('message');\n subscription.removeAllListeners('error');\n\n subscription.on('message', (message) => {\n handleMessage(message as Message, subscription, handlers, isDebezium).catch(reportError);\n });\n\n subscription.on('error', (error) => {\n reportError(error);\n // Reconnect on transient errors (DEADLINE_EXCEEDED, UNAVAILABLE, INTERNAL)\n const code = (error as any)?.code;\n if (code === 4 || code === 14 || code === 13) {\n reattachSubscription(subscriptionName, Math.min(delayMs * 2, 60000));\n }\n });\n }, delayMs);\n}\n\nexport const PubSub = {\n /**\n * ✅ FAST + NON-BLOCKING INIT\n */\n async init(): Promise<void> {\n reportDebug({ namespace, message: `Initializing Pub/Sub (safe mode)` });\n\n for (const [subscriptionName, { subscription, handlers, isDebezium }] of Object.entries(\n subscriptions\n )) {\n subscription.on('message', (message) => {\n handleMessage(\n message as Message,\n subscription,\n handlers,\n isDebezium\n ).catch(reportError);\n });\n\n subscription.on('error', (error) => {\n reportError(error);\n // Auto-reconnect on transient gRPC errors (DEADLINE_EXCEEDED=4, UNAVAILABLE=14, INTERNAL=13)\n const code = (error as any)?.code;\n if (code === 4 || code === 14 || code === 13) {\n reattachSubscription(subscriptionName, 5000);\n }\n });\n }\n\n LifecycleController.register(PubSub);\n },\n\n /**\n * Shutdown\n */\n async shutdown(): Promise<void> {\n reportDebug({ namespace, message: `Shutting down Pub/Sub` });\n\n await Promise.all([\n ...Object.values(topics).map(async (topic) => topic.flush()),\n ...Object.values(subscriptions).map(async ({ subscription }) =>\n subscription.close()\n )\n ]);\n\n Object.keys(topics).forEach((topic) => delete topics[topic]);\n Object.keys(subscriptions).forEach(\n (subscription) => delete subscriptions[subscription]\n );\n\n await pubSubClient.close();\n },\n\n /**\n * Publisher registration\n */\n addPublisher(\n topic: string | Array<string>,\n options?: PubSubPublisherOptions\n ): void {\n const topicArray = topic instanceof Array ? topic : [topic];\n\n reportDebug({\n namespace,\n message: `Registering publisher for topics '${topicArray.join(\"', '\")}'`,\n data: options\n });\n\n for (const topic of topicArray) {\n if (!topics[topic]) {\n topics[topic] = pubSubClient.topic(topic, {\n enableOpenTelemetryTracing: true,\n messageOrdering: options?.enableMessageOrdering ?? false,\n batching: options?.batching\n ? {\n maxMessages: options.batching.maxMessages ?? 100,\n maxBytes: options.batching.maxBytes ?? 1024 * 1024,\n maxMilliseconds: options.batching.maxMilliseconds ?? 100\n }\n : undefined\n });\n }\n }\n },\n\n /**\n * Subscriber registration\n */\n addSubscriber<T>(\n subscriptionName: string,\n handler: PubSubMessageHandler<T> | Array<PubSubMessageHandler<T>>,\n options: PubSubAddSubscriberOptions = {}\n ): void {\n const handlers = handler instanceof Array ? handler : [handler];\n\n reportDebug({\n namespace,\n message: `Registering subscriber '${subscriptionName}'`,\n data: options\n });\n\n if (!subscriptions[subscriptionName]) {\n subscriptions[subscriptionName] = {\n subscription: pubSubClient.subscription(subscriptionName, {\n enableOpenTelemetryTracing: true,\n flowControl: options.flowControl ?? {\n maxMessages: 1000,\n maxBytes: 100 * 1024 * 1024,\n allowExcessMessages: true\n },\n ackDeadline: options.ackDeadline ?? 60\n }),\n handlers: [],\n isDebezium: options?.isDebezium ?? false\n };\n }\n\n if (options.first)\n subscriptions[subscriptionName].handlers.push(...handlers);\n else subscriptions[subscriptionName].handlers.unshift(...handlers);\n },\n\n /**\n * ✅ SAFE PUBLISH (with retry)\n */\n async publish(\n topic: string,\n message: unknown,\n attributes?: Attributes,\n orderingKey?: string\n ): Promise<void> {\n if (!topics[topic]) {\n throw new EngineError(`No publisher registered for topic '${topic}'`);\n }\n\n reportDebug({\n namespace,\n message: `Publishing to '${topic}'`,\n data: { message, attributes, orderingKey }\n });\n\n await withRetry(() =>\n topics[topic].publishMessage({\n json: message,\n attributes,\n orderingKey\n })\n );\n }\n};"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,cAAA,GAAAD,OAAA;AAQA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,GAAG,eAAe;AAEjC,MAAMC,aAAqC,GAAG,CAAC,CAAC;AAChD,MAAMC,MAAuB,GAAG,CAAC,CAAC;;AAElC;AACA;AACA;AACA,MAAMC,SAAS,GAAG,MAAAA,CAChBC,EAAoB,EACpBC,OAAO,GAAG,CAAC,EACXC,KAAK,GAAG,GAAG,KACI;EACf,IAAIC,SAAc;EAClB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,EAAEG,CAAC,EAAE,EAAE;IAChC,IAAI;MACF,OAAO,MAAMJ,EAAE,CAAC,CAAC;IACn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Aa,EACbrB,OAAgB,EAChBiD,UAAuB,EACvBC,WAAoB,EACL;IACf,IAAI,CAACxE,MAAM,CAAC2C,KAAK,CAAC,EAAE;MAClB,MAAM,IAAI8B,wBAAW,CAAC,sCAAsC9B,KAAK,GAAG,CAAC;IACvE;IAEA,IAAAtB,kBAAW,EAAC;MACVvB,SAAS;MACTwB,OAAO,EAAE,kBAAkBqB,KAAK,GAAG;MACnCU,IAAI,EAAE;QAAE/B,OAAO;QAAEiD,UAAU;QAAEC;MAAY;IAC3C,CAAC,CAAC;IAEF,MAAMvE,SAAS,CAAC,MACdD,MAAM,CAAC2C,KAAK,CAAC,CAAC+B,cAAc,CAAC;MAC3BC,IAAI,EAAErD,OAAO;MACbiD,UAAU;MACVC;IACF,CAAC,CACH,CAAC;EACH;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-server-engine",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3",
|
|
4
4
|
"description": "Framework used to develop backend services. This package ships with a lot of features to standardize the creation of services, letting you focus on the business logic.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|