Class: Quebert::Backend::Beanstalk

Inherits:
Beanstalk::Pool
  • Object
show all
Defined in:
lib/quebert/backend/beanstalk.rb

Overview

Manage jobs on a Beanstalk queue out of process

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, *args) ⇒ Beanstalk

Returns a new instance of Beanstalk.



32
33
34
# File 'lib/quebert/backend/beanstalk.rb', line 32

def initialize(host, *args)
  super Array(host), *args
end

Class Method Details

.configure(opts = {}) ⇒ Object



35
36
37
38
# File 'lib/quebert/backend/beanstalk.rb', line 35

def self.configure(opts={})
  opts[:host] ||= ['127.0.0.1:11300']
  new(opts[:host], opts[:tube])
end

Instance Method Details

#drain!Object

For testing purposes… I think there’s a better way to do this though.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/quebert/backend/beanstalk.rb', line 19

def drain!
  while peek_ready do
    reserve_without_controller.delete
  end
  while peek_delayed do
    reserve_without_controller.delete
  end
  while job = peek_buried do
    last_conn.kick 1 # what? Why the 1? it kicks them all?
    reserve_without_controller.delete
  end
end

#put(job, *args) ⇒ Object



8
9
10
# File 'lib/quebert/backend/beanstalk.rb', line 8

def put(job, *args)
  super job.to_json, *args
end

#reserve_with_controllerObject Also known as: reserve



12
13
14
# File 'lib/quebert/backend/beanstalk.rb', line 12

def reserve_with_controller
  Controller::Beanstalk.new(reserve_without_controller, self)
end