grantcarthew / node-rethinkdb-job-queue

A persistent job or task queue backed by RethinkDB.
https://github.com/grantcarthew/node-rethinkdb-job-queue/wiki
MIT License
156 stars 16 forks source link

Global queue pause #10

Closed TomKaltz closed 8 years ago

grantcarthew commented 8 years ago

@TomKaltz. Yes, I tried to come up with a idea for global pause a couple of months ago. Only recently I thought of a pub/sub method I could use to give global pause.

I'll think on it more.

TomKaltz commented 8 years ago

Why not have a table that holds queue names and metadata for that queue such as paused state. That way all workers can listen to changefeed of the paused property of the pertaining queue row?

grantcarthew commented 8 years ago

I've spent a few hours on this today, and it works perfectly. Published in v0.3.0. The final approach I took was to used a fixed document id in the database and just update it with global status. This causes the change feed to update the worker Queue objects.

Just call Queue.pause(true) for a global pause. Without the true it is a local pause only.

I'll update the docs when I can.

Thanks again.