summaryrefslogtreecommitdiff
path: root/lib/custodian/queue.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-02-05 11:30:35 +0000
committerSteve Kemp <steve@steve.org.uk>2015-02-05 11:30:35 +0000
commit12740c13dd36045ddbf86626e4b32455be2c5adf (patch)
tree7d8b9d9020246bcd225359472d24ea77b5e87726 /lib/custodian/queue.rb
parent255b03c6c79e3a48e61f7499654e4dd36fdbceb9 (diff)
Simplify code by removing configuration.
We now set the queue-address via $QUEUE_ADDRESS, otherwise we default to localhost. This works for both redis & beanstalkd.
Diffstat (limited to 'lib/custodian/queue.rb')
-rw-r--r--lib/custodian/queue.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb
index d3513c3..67c5346 100644
--- a/lib/custodian/queue.rb
+++ b/lib/custodian/queue.rb
@@ -76,10 +76,10 @@ end
#
- # Connect to the server on localhost
+ # Connect to the server on localhost, unless QUEUE_ADDRESS is set.
#
def initialize
- host = ENV["REDIS"] || "127.0.0.1"
+ host = ENV["QUEUE_ADDRESS"] || "127.0.0.1"
@redis = Redis.new( :host => host )
end
@@ -124,11 +124,11 @@ end
class BeanstalkQueueType < QueueType
#
- # Connect to the server on localhost
+ # Connect to the server on localhost, unless QUEUE_ADDRESS is set.
#
def initialize
- host = ENV["QUEUE"] || "127.0.0.1:11300"
- @queue = Beanstalk::Pool.new([host] )
+ host = ENV["QUEUE_ADDRESS"] || "127.0.0.1"
+ @queue = Beanstalk::Pool.new( ["#{host}:11300" ] )
end
#
@@ -168,8 +168,10 @@ end
( stats['current-jobs-ready'] || 0 )
end
+ #
+ # Flush the queue.
+ #
def flush!
-
while( fetch(1) )
# nop
end