summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-12-18 11:56:32 +0200
committerSteve Kemp <steve@steve.org.uk>2015-12-18 11:56:32 +0200
commitca00933b7094642f218d428bf663f99f9c5e524d (patch)
tree4ea24656009aa5897293bde481ca391e42290515 /lib
parent048e2bfb8e8bdb152d5373b47dd54553e40e5b78 (diff)
Removed references and support for beanstalkd.
The beanstalkd queue used to be used in the past, and we later added support for Redis via a simple abstraction layer. But now we've no longer tested and used beanstalkd for over a year, and the client-libraries are no longer available as native Debian packages. With that in mind we've excised the code, although left the abstraction-class in-place.
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/queue.rb88
-rw-r--r--lib/custodian/worker.rb2
2 files changed, 6 insertions, 84 deletions
diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb
index d919e07..8c8ea98 100644
--- a/lib/custodian/queue.rb
+++ b/lib/custodian/queue.rb
@@ -1,12 +1,13 @@
#
-# We don't necessarily expect that both libraries will be present,
-# so long as one is that'll allow things to work.
+# Attempt to load the Redis-library.
#
-%w( redis beanstalk-client ).each do |library|
+# Without this we cannot connect to our queue.
+#
+%w( redis ).each do |library|
begin
require library
rescue LoadError
- ENV['DEBUG'] && puts("Failed to load the library: #{library}")
+ puts("Failed to load the #{library} library - queue access will fail!")
end
end
@@ -21,21 +22,6 @@ module Custodian
class QueueType
#
- # Class-Factory
- #
- def self.create(type)
- case type
- when 'redis'
- RedisQueueType.new
- when 'beanstalk'
- BeanstalkQueueType.new
- else
- raise "Bad queue-type: #{type}"
- end
- end
-
-
- #
# Retrieve a job from the queue.
#
def fetch(_timeout)
@@ -165,68 +151,4 @@ module Custodian
end
-
-
- #
- # Use the beanstalkd-queue for its intended purpose
- #
- class BeanstalkQueueType < QueueType
-
- #
- # Connect to the server on localhost, unless QUEUE_ADDRESS is set.
- #
- def initialize
- host = ENV['QUEUE_ADDRESS'] || '127.0.0.1'
- @queue = Beanstalk::Pool.new(["#{host}:11300"])
- end
-
-
- #
- # Here we fetch a value from the queue, and delete it at the same time.
- #
- # The timeout is used to specify the period we wait for a new job.
- #
- def fetch(timeout)
- begin
- j = @queue.reserve(timeout)
- if j then
- b = j.body
- j.delete
- return b
- else
- raise 'ERRROR'
- end
- rescue Beanstalk::TimedOut => _ex
- return nil
- end
- end
-
-
- #
- # Add a new job to the queue.
- #
- def add(job_string)
- @queue.put(job_string)
- end
-
-
- #
- # Get the size of the queue
- #
- def size?
- stats = @queue.stats
- (stats['current-jobs-ready'] || 0)
- end
-
-
- #
- # Flush the queue, discarding all pending jobs.
- #
- def flush!
- while fetch(1)
- # nop
- end
- end
- end
-
end
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index ef162b2..3c71838 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -73,7 +73,7 @@ module Custodian
@settings = settings
# Connect to the queue
- @queue = QueueType.create(@settings.queue_type)
+ @queue = RedisQueueType.new()
# Get the alerter-type(s) to instantiate
@alerter = @settings.alerter