From eaa6fd78cc6fd2eacd2d551e7eded0e899458258 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 5 Feb 2015 10:28:39 +0000 Subject: Simplify the flushing of queues. Now that we've moved to using redis by default the handling of queue-flushing needs to change. We can simply get rid of the busy-wait and run a redis "del" operation. With that in mind we've moved the flushing logic to our queue abstraction layer, and simplified our queue-helper script. --- lib/custodian/queue.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/custodian') diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb index 8d48575..d3513c3 100644 --- a/lib/custodian/queue.rb +++ b/lib/custodian/queue.rb @@ -58,7 +58,13 @@ module Custodian raise "Subclasses must implement this method!" end - end + # + # Empty the queue + # + def flush!() + raise "Subclasses must implement this method!" + end +end @@ -103,6 +109,11 @@ module Custodian def size? @redis.llen( "queue" ) end + + def flush! + @redis.del( "queue" ) + end + end @@ -157,6 +168,12 @@ module Custodian ( stats['current-jobs-ready'] || 0 ) end + def flush! + + while( fetch(1) ) + # nop + end + end end end -- cgit v1.2.1