bull队列提供了 pause/resume 方法来暂停/恢复job的执行,同时它们又分成了 local/global两种
如果是local的pause,只是设置一个 this.paused 的 Promise,然后调用 resumeLocal 恢复
doNotWaitActive 则代表停滞 bclient 的 block 操作,不要再等待 wait to active 队列的 job
Queue.prototype.pause = function(isLocal, doNotWaitActive) {
return this.isReady()
.then(() => {
if (isLocal) {
if (!this.paused) {
this.paused = new Promise(resolve => {
this.resumeLocal = function() {
this.paused = null; // Allow pause to be checked externally for paused state.
resolve();
};
});
}
if (!this.bclientInitialized) {
// bclient not yet initialized, so no jobs to wait for
return;
Bull队列提供了local和global两种方式的pause/resume功能。local pause仅设置内部状态,而global pause通过Redis脚本改变wait队列名称和meta-paused标志。在恢复时,local resume解决Promise,而global resume调用相应脚本还原队列状态。操作需对应,避免混淆。
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



