sqs-consumer 8.2.0 → 9.0.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/.github/workflows/publish.yml +0 -2
- package/CHANGELOG.md +13 -4
- package/README.md +12 -2
- package/dist/consumer.d.ts +6 -2
- package/dist/consumer.js +10 -11
- package/dist/types.d.ts +8 -0
- package/package.json +26 -22
- package/src/consumer.ts +13 -14
- package/src/types.ts +8 -0
|
@@ -17,8 +17,6 @@ jobs:
|
|
|
17
17
|
cache: 'npm'
|
|
18
18
|
registry-url: 'https://registry.npmjs.org'
|
|
19
19
|
- run: npm ci
|
|
20
|
-
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
|
|
21
|
-
run: npm audit signatures
|
|
22
20
|
- name: Release
|
|
23
21
|
env:
|
|
24
22
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [9.0.0](https://github.com/bbc/sqs-consumer/compare/v8.2.0...v9.0.0) (2024-03-11)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
### ⚠ BREAKING CHANGES
|
|
5
|
+
|
|
6
|
+
* removing handler_processing debugger in favour of status (#470)
|
|
7
|
+
* replacing the isRunning method with status (#459)
|
|
8
|
+
|
|
4
9
|
### Features
|
|
5
10
|
|
|
6
|
-
*
|
|
11
|
+
* removing handler_processing debugger in favour of status ([#470](https://github.com/bbc/sqs-consumer/issues/470)) ([b554da6](https://github.com/bbc/sqs-consumer/commit/b554da6e700bc0e69b77032352f250f19dba081b))
|
|
12
|
+
* replacing the isRunning method with status ([#459](https://github.com/bbc/sqs-consumer/issues/459)) ([9f07383](https://github.com/bbc/sqs-consumer/commit/9f07383b0244fa0ce05238c45f27238cd3459ebf))
|
|
7
13
|
|
|
8
14
|
|
|
9
15
|
### Chores
|
|
10
16
|
|
|
11
|
-
*
|
|
12
|
-
*
|
|
17
|
+
* adding a link to the documentation ([#471](https://github.com/bbc/sqs-consumer/issues/471)) ([bd7fbbb](https://github.com/bbc/sqs-consumer/commit/bd7fbbb78a7e1d10cb7eae1b7d8f595c48b3438e))
|
|
18
|
+
* **deps:** upgrading dependencies - March 24 ([#468](https://github.com/bbc/sqs-consumer/issues/468)) ([2d342cd](https://github.com/bbc/sqs-consumer/commit/2d342cd63365bb42c095e2d4f56a7e2433f43f25))
|
|
19
|
+
* handle breaking changes ([2924ca2](https://github.com/bbc/sqs-consumer/commit/2924ca24e9fda687bf47a5daf45d17618561dae1))
|
|
20
|
+
* **release:** v9.0.0 ([bc5593c](https://github.com/bbc/sqs-consumer/commit/bc5593c4f9940e30c05e6463a1e7339bf14f1e50))
|
|
21
|
+
* upgrading @semantic-release/npm ([bed4dc6](https://github.com/bbc/sqs-consumer/commit/bed4dc63e42344325de0be398952c2b99994e631))
|
package/README.md
CHANGED
|
@@ -26,6 +26,10 @@ npm install sqs-consumer
|
|
|
26
26
|
|
|
27
27
|
We will only support Node versions that are actively or security supported by the Node team. If you are still using an Node 14, please use a version of this library before the v7 release, if you are using Node 16, please use a version before the v7.3.0 release.
|
|
28
28
|
|
|
29
|
+
## Documentation
|
|
30
|
+
|
|
31
|
+
Visit [https://bbc.github.io/sqs-consumer/](https://bbc.github.io/sqs-consumer/) for the full API documentation.
|
|
32
|
+
|
|
29
33
|
## Usage
|
|
30
34
|
|
|
31
35
|
```js
|
|
@@ -125,9 +129,15 @@ By default, the value of `abort` is set to `false` which means pre existing requ
|
|
|
125
129
|
|
|
126
130
|
`consumer.stop({ abort: true })`
|
|
127
131
|
|
|
128
|
-
### `consumer.
|
|
132
|
+
### `consumer.status`
|
|
133
|
+
|
|
134
|
+
Returns the current status of the consumer.
|
|
135
|
+
|
|
136
|
+
- `isRunning` - `true` if the consumer has been started and not stopped, `false` if was not started or if it was stopped.
|
|
137
|
+
- `isPolling` - `true` if the consumer is actively polling, `false` if it is not.
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
> **Note:**
|
|
140
|
+
> This method is not available in versions before v9.0.0 and replaced the method `isRunning` to supply both running and polling states.
|
|
131
141
|
|
|
132
142
|
### `consumer.updateOption(option, value)`
|
|
133
143
|
|
package/dist/consumer.d.ts
CHANGED
|
@@ -51,9 +51,13 @@ export declare class Consumer extends TypedEventEmitter {
|
|
|
51
51
|
*/
|
|
52
52
|
private waitForPollingToComplete;
|
|
53
53
|
/**
|
|
54
|
-
* Returns the current
|
|
54
|
+
* Returns the current status of the consumer.
|
|
55
|
+
* This includes whether it is running or currently polling.
|
|
55
56
|
*/
|
|
56
|
-
get
|
|
57
|
+
get status(): {
|
|
58
|
+
isRunning: boolean;
|
|
59
|
+
isPolling: boolean;
|
|
60
|
+
};
|
|
57
61
|
/**
|
|
58
62
|
* Validates and then updates the provided option to the provided value.
|
|
59
63
|
* @param option The option to validate and then update
|
package/dist/consumer.js
CHANGED
|
@@ -16,6 +16,7 @@ class Consumer extends emitter_1.TypedEventEmitter {
|
|
|
16
16
|
super();
|
|
17
17
|
this.pollingTimeoutId = undefined;
|
|
18
18
|
this.stopped = true;
|
|
19
|
+
this.isPolling = false;
|
|
19
20
|
(0, validation_1.assertOptions)(options);
|
|
20
21
|
this.queueUrl = options.queueUrl;
|
|
21
22
|
this.handleMessage = options.handleMessage;
|
|
@@ -108,18 +109,22 @@ class Consumer extends emitter_1.TypedEventEmitter {
|
|
|
108
109
|
const exceededTimeout = Date.now() - this.stopRequestedAtTimestamp >
|
|
109
110
|
this.pollingCompleteWaitTimeMs;
|
|
110
111
|
if (exceededTimeout) {
|
|
111
|
-
|
|
112
|
+
this.emit('waiting_for_polling_to_complete_timeout_exceeded');
|
|
112
113
|
this.emit('stopped');
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
this.emit('waiting_for_polling_to_complete');
|
|
116
117
|
setTimeout(this.waitForPollingToComplete, 1000);
|
|
117
118
|
}
|
|
118
119
|
/**
|
|
119
|
-
* Returns the current
|
|
120
|
+
* Returns the current status of the consumer.
|
|
121
|
+
* This includes whether it is running or currently polling.
|
|
120
122
|
*/
|
|
121
|
-
get
|
|
122
|
-
return
|
|
123
|
+
get status() {
|
|
124
|
+
return {
|
|
125
|
+
isRunning: !this.stopped,
|
|
126
|
+
isPolling: this.isPolling
|
|
127
|
+
};
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
130
|
* Validates and then updates the provided option to the provided value.
|
|
@@ -221,18 +226,12 @@ class Consumer extends emitter_1.TypedEventEmitter {
|
|
|
221
226
|
*/
|
|
222
227
|
async handleSqsResponse(response) {
|
|
223
228
|
if ((0, validation_1.hasMessages)(response)) {
|
|
224
|
-
const handlerProcessingDebugger = setInterval(() => {
|
|
225
|
-
logger_1.logger.debug('handler_processing', {
|
|
226
|
-
detail: 'The handler is still processing the message(s)...'
|
|
227
|
-
});
|
|
228
|
-
}, 1000);
|
|
229
229
|
if (this.handleMessageBatch) {
|
|
230
230
|
await this.processMessageBatch(response.Messages);
|
|
231
231
|
}
|
|
232
232
|
else {
|
|
233
233
|
await Promise.all(response.Messages.map(this.processMessage));
|
|
234
234
|
}
|
|
235
|
-
clearInterval(handlerProcessingDebugger);
|
|
236
235
|
this.emit('response_processed');
|
|
237
236
|
}
|
|
238
237
|
else if (response) {
|
package/dist/types.d.ts
CHANGED
|
@@ -189,6 +189,14 @@ export interface Events {
|
|
|
189
189
|
* Fired when an option is updated
|
|
190
190
|
*/
|
|
191
191
|
option_updated: [UpdatableOptions, ConsumerOptions[UpdatableOptions]];
|
|
192
|
+
/**
|
|
193
|
+
* Fired when the Consumer is waiting for polling to complete before stopping.
|
|
194
|
+
*/
|
|
195
|
+
waiting_for_polling_to_complete: [];
|
|
196
|
+
/**
|
|
197
|
+
* Fired when the Consumer has waited for polling to complete and is stopping due to a timeout.
|
|
198
|
+
*/
|
|
199
|
+
waiting_for_polling_to_complete_timeout_exceeded: [];
|
|
192
200
|
}
|
|
193
201
|
export type AWSError = {
|
|
194
202
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqs-consumer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Build SQS-based Node applications without the boilerplate",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lcov": "c8 mocha && c8 report --reporter=lcov",
|
|
22
22
|
"lint": "eslint . --ext .ts",
|
|
23
23
|
"lint:fix": "eslint . --fix",
|
|
24
|
-
"format": "prettier --
|
|
24
|
+
"format": "prettier --log-level warn --write \"**/*.{js,json,jsx,md,ts,tsx,html}\"",
|
|
25
25
|
"format:check": "prettier --check \"**/*.{js,json,jsx,md,ts,tsx,html}\"",
|
|
26
26
|
"posttest": "npm run lint && npm run format:check",
|
|
27
27
|
"generate-docs": "typedoc"
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
{
|
|
58
58
|
"preset": "conventionalcommits",
|
|
59
59
|
"releaseRules": [
|
|
60
|
+
{
|
|
61
|
+
"type": "breaking",
|
|
62
|
+
"release": "major"
|
|
63
|
+
},
|
|
60
64
|
{
|
|
61
65
|
"type": "feat",
|
|
62
66
|
"release": "minor"
|
|
@@ -124,39 +128,39 @@
|
|
|
124
128
|
]
|
|
125
129
|
},
|
|
126
130
|
"devDependencies": {
|
|
127
|
-
"@cucumber/cucumber": "10.
|
|
131
|
+
"@cucumber/cucumber": "10.3.1",
|
|
128
132
|
"@semantic-release/changelog": "^6.0.3",
|
|
129
133
|
"@semantic-release/commit-analyzer": "^11.1.0",
|
|
130
134
|
"@semantic-release/git": "^10.0.1",
|
|
131
135
|
"@semantic-release/github": "^9.2.6",
|
|
132
|
-
"@semantic-release/npm": "
|
|
136
|
+
"@semantic-release/npm": "11.0.3",
|
|
133
137
|
"@semantic-release/release-notes-generator": "^12.1.0",
|
|
134
|
-
"@types/chai": "^4.3.
|
|
135
|
-
"@types/mocha": "^10.0.
|
|
136
|
-
"@types/node": "^20.
|
|
137
|
-
"@types/sinon": "^
|
|
138
|
-
"c8": "^
|
|
138
|
+
"@types/chai": "^4.3.12",
|
|
139
|
+
"@types/mocha": "^10.0.6",
|
|
140
|
+
"@types/node": "^20.11.25",
|
|
141
|
+
"@types/sinon": "^17.0.3",
|
|
142
|
+
"c8": "^9.1.0",
|
|
139
143
|
"chai": "^4.3.10",
|
|
140
144
|
"conventional-changelog-conventionalcommits": "^7.0.2",
|
|
141
|
-
"eslint": "^8.
|
|
142
|
-
"eslint-config-iplayer": "^9.
|
|
143
|
-
"eslint-config-prettier": "^9.
|
|
144
|
-
"mocha": "^10.
|
|
145
|
+
"eslint": "^8.57.0",
|
|
146
|
+
"eslint-config-iplayer": "^9.2.0",
|
|
147
|
+
"eslint-config-prettier": "^9.1.0",
|
|
148
|
+
"mocha": "^10.3.0",
|
|
145
149
|
"p-event": "^4.2.0",
|
|
146
|
-
"prettier": "^3.
|
|
147
|
-
"semantic-release": "^23.0.
|
|
148
|
-
"sinon": "^17.0.
|
|
149
|
-
"sqs-producer": "^
|
|
150
|
-
"ts-node": "^10.9.
|
|
151
|
-
"typedoc": "^0.25.
|
|
152
|
-
"typescript": "^5.
|
|
150
|
+
"prettier": "^3.2.5",
|
|
151
|
+
"semantic-release": "^23.0.2",
|
|
152
|
+
"sinon": "^17.0.1",
|
|
153
|
+
"sqs-producer": "^5.0.0",
|
|
154
|
+
"ts-node": "^10.9.2",
|
|
155
|
+
"typedoc": "^0.25.12",
|
|
156
|
+
"typescript": "^5.4.2"
|
|
153
157
|
},
|
|
154
158
|
"dependencies": {
|
|
155
|
-
"@aws-sdk/client-sqs": "^3.
|
|
159
|
+
"@aws-sdk/client-sqs": "^3.529.1",
|
|
156
160
|
"debug": "^4.3.4"
|
|
157
161
|
},
|
|
158
162
|
"peerDependencies": {
|
|
159
|
-
"@aws-sdk/client-sqs": "^3.
|
|
163
|
+
"@aws-sdk/client-sqs": "^3.529.1"
|
|
160
164
|
},
|
|
161
165
|
"mocha": {
|
|
162
166
|
"spec": "test/tests/**/**/*.test.ts",
|
package/src/consumer.ts
CHANGED
|
@@ -56,7 +56,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
56
56
|
private pollingWaitTimeMs: number;
|
|
57
57
|
private pollingCompleteWaitTimeMs: number;
|
|
58
58
|
private heartbeatInterval: number;
|
|
59
|
-
private isPolling
|
|
59
|
+
private isPolling = false;
|
|
60
60
|
private stopRequestedAtTimestamp: number;
|
|
61
61
|
public abortController: AbortController;
|
|
62
62
|
|
|
@@ -164,20 +164,27 @@ export class Consumer extends TypedEventEmitter {
|
|
|
164
164
|
Date.now() - this.stopRequestedAtTimestamp >
|
|
165
165
|
this.pollingCompleteWaitTimeMs;
|
|
166
166
|
if (exceededTimeout) {
|
|
167
|
-
|
|
167
|
+
this.emit('waiting_for_polling_to_complete_timeout_exceeded');
|
|
168
168
|
this.emit('stopped');
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
this.emit('waiting_for_polling_to_complete');
|
|
173
173
|
setTimeout(this.waitForPollingToComplete, 1000);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
* Returns the current
|
|
177
|
+
* Returns the current status of the consumer.
|
|
178
|
+
* This includes whether it is running or currently polling.
|
|
178
179
|
*/
|
|
179
|
-
public get
|
|
180
|
-
|
|
180
|
+
public get status(): {
|
|
181
|
+
isRunning: boolean;
|
|
182
|
+
isPolling: boolean;
|
|
183
|
+
} {
|
|
184
|
+
return {
|
|
185
|
+
isRunning: !this.stopped,
|
|
186
|
+
isPolling: this.isPolling
|
|
187
|
+
};
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
/**
|
|
@@ -297,20 +304,12 @@ export class Consumer extends TypedEventEmitter {
|
|
|
297
304
|
response: ReceiveMessageCommandOutput
|
|
298
305
|
): Promise<void> {
|
|
299
306
|
if (hasMessages(response)) {
|
|
300
|
-
const handlerProcessingDebugger = setInterval(() => {
|
|
301
|
-
logger.debug('handler_processing', {
|
|
302
|
-
detail: 'The handler is still processing the message(s)...'
|
|
303
|
-
});
|
|
304
|
-
}, 1000);
|
|
305
|
-
|
|
306
307
|
if (this.handleMessageBatch) {
|
|
307
308
|
await this.processMessageBatch(response.Messages);
|
|
308
309
|
} else {
|
|
309
310
|
await Promise.all(response.Messages.map(this.processMessage));
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
clearInterval(handlerProcessingDebugger);
|
|
313
|
-
|
|
314
313
|
this.emit('response_processed');
|
|
315
314
|
} else if (response) {
|
|
316
315
|
this.emit('empty');
|
package/src/types.ts
CHANGED
|
@@ -197,6 +197,14 @@ export interface Events {
|
|
|
197
197
|
* Fired when an option is updated
|
|
198
198
|
*/
|
|
199
199
|
option_updated: [UpdatableOptions, ConsumerOptions[UpdatableOptions]];
|
|
200
|
+
/**
|
|
201
|
+
* Fired when the Consumer is waiting for polling to complete before stopping.
|
|
202
|
+
*/
|
|
203
|
+
waiting_for_polling_to_complete: [];
|
|
204
|
+
/**
|
|
205
|
+
* Fired when the Consumer has waited for polling to complete and is stopping due to a timeout.
|
|
206
|
+
*/
|
|
207
|
+
waiting_for_polling_to_complete_timeout_exceeded: [];
|
|
200
208
|
}
|
|
201
209
|
|
|
202
210
|
export type AWSError = {
|