Module: Restalk::BeanstalkAdapter
- Defined in:
- lib/restalk.rb
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #init(server = nil, queue = nil) ⇒ Object
- #pop ⇒ Object
- #push(data) ⇒ Object
- #stats ⇒ Object
Instance Method Details
#connected? ⇒ Boolean
43 |
# File 'lib/restalk.rb', line 43 def connected?; true; end |
#init(server = nil, queue = nil) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/restalk.rb', line 24 def init(server = nil, queue = nil) require 'beaneater' @beanstalk = Beaneater::Pool.new([server || ENV['BEANSTALK'] || '127.0.0.1:11300']) tube = queue || ENV['BEANSTALK_QUEUE'] || 'default' @beanstalk = @beanstalk.tubes[tube] end |
#pop ⇒ Object
35 36 37 |
# File 'lib/restalk.rb', line 35 def pop @beanstalk.reserve if @beanstalk.peek(:ready) end |
#push(data) ⇒ Object
31 32 33 |
# File 'lib/restalk.rb', line 31 def push(data) @beanstalk.put(data) end |
#stats ⇒ Object
39 40 41 |
# File 'lib/restalk.rb', line 39 def stats @beanstalk.stats end |