Module: Restalk::BeanstalkAdapter

Defined in:
lib/restalk.rb

Instance Method Summary collapse

Instance Method Details

#connected?Boolean

Returns:

  • (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

#popObject



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

#statsObject



39
40
41
# File 'lib/restalk.rb', line 39

def stats
  @beanstalk.stats
end