Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 05e16dc

Browse files
committed
Merge pull request #14 from firebase/1-1-0
v1.1.0 release candidate
2 parents 3cc7994 + 1a96bf4 commit 05e16dc

File tree

7 files changed

+503
-274
lines changed

7 files changed

+503
-274
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,27 @@ queue
320320
}
321321
```
322322

323+
## Graceful Shutdown
324+
325+
Once initialized, a queue can be gracefully shutdown by calling its `shutdown()` function. This prevents workers from claiming new tasks, removes all Firebase listeners, and waits until all the current tasks have been completed before resolving the RSVP.Promise returned by the function.
326+
327+
By intercepting for the `SIGINT` termination signal like this, you can ensure the queue shuts down gracefully so you don't have to rely on the jobs timing out and being picked up by another worker:
328+
329+
```js
330+
...
331+
var queue = new Queue(ref, function(data, progress, resolve, reject) {
332+
...
333+
});
334+
335+
process.on('SIGINT', function() {
336+
console.log('Starting queue shutdown');
337+
queue.shutdown().then(function() {
338+
console.log('Finished queue shutdown');
339+
process.exit(0);
340+
});
341+
});
342+
```
343+
323344
## Message Sanitization, Revisited
324345

325346
In our example at the beginning, you wanted to perform several actions on your chat system:

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changed - `Queue` constructor returns the instantiated queue instead of a promise
2+
feature - Graceful shutdown of a queue is now possible using the instantiated object's `shutdown()` method
3+
feature - Synchronously thrown errors in a `processingFunction` are now caught and passed to the `reject()` handler
4+
changed - All logging is now at Winston's `debug` level to reduce log pollution

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"README.md",
3838
"package.json"
3939
],
40+
"peerDependencies": {
41+
"firebase": "2.x"
42+
},
4043
"dependencies": {
4144
"firebase": "2.x",
4245
"lodash": "~3.7.0",

0 commit comments

Comments
 (0)