diff options
| author | Steve Kemp <steve@steve.org.uk> | 2015-02-05 10:28:39 +0000 | 
|---|---|---|
| committer | Steve Kemp <steve@steve.org.uk> | 2015-02-05 10:28:39 +0000 | 
| commit | f89d370d90be2173c2d670dab03b79daaa3eb685 (patch) | |
| tree | b41f5f58d97ff98aa5be108073d6b70c219122c0 /lib | |
| parent | a5fa7e1b72562b7a643810ea4fb01680081c2dd4 (diff) | |
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.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/custodian/queue.rb | 19 | 
1 files changed, 18 insertions, 1 deletions
| 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 | 
