Yes, that makes sense.
However, is there a way to delete the queue for a specific task? For example, if I enqueue three tasks:
api.tasks.enqueue('crawl', {url:url, crawler_id:crawler_id}, 'default');
api.tasks.enqueue('crawl', {url:url, crawler_id:crawler_id}, 'default');
api.tasks.enqueue('crawl', {url:url, crawler_id:crawler_id}, 'default');
And then hit a route /api/stop_crawler?crawler_id=1, I want to be able to delete the above three enqueued tasks. For example, if the following code could be run, that would be ideal for what I'm trying to do:
api.tasks.dequeue('crawl', {crawler_id:crawler_id}, 'default'); // delete all enqueued tasks that match crawler_id:crawler_id
But, I
really don't think there is a way to do this. For one, Resque uses a
LIST data type in Redis, which has only one option for deleting,
LREM, which requires that you know the entire value that you inserted into the list. And two, if I just run `
del resque:queue:default` directly to Redis it will delete any other tasks that have been sent to the "default" queue, regardless of what crawler_id it is. In other words, this would halt ALL crawlers.
So, I think instead of using the Action Hero's task API for enqueuing tasks to keep track of my queue for URLs to crawl, I will create a new queue for each crawler using the Resque API directly. Then, I should be able to run: `del resque:que:<crawler_id>` where the crawler_id is the crawler I want to stop.