class Ayl::Beanstalk::Engine
Attributes
host[R]
port[R]
Public Class Methods
new(host='localhost', port=11300)
click to toggle source
# File lib/ayl-beanstalk/engine.rb, line 11 def initialize(host='localhost', port=11300) logger.debug "#{self.class.name}.initialize(#{host.inspect}, #{port})" @host = host @port = port end
Public Instance Methods
asynchronous?()
click to toggle source
# File lib/ayl-beanstalk/engine.rb, line 17 def asynchronous?() true end
is_connected?()
click to toggle source
# File lib/ayl-beanstalk/engine.rb, line 19 def is_connected? connected = true begin pool rescue ::Beaneater::NotConnected => ex logger.error "#{self.class.name} not connected error: #{ex}" connected = false end connected end
submit(message)
click to toggle source
# File lib/ayl-beanstalk/engine.rb, line 30 def submit(message) log_call(:submit) do begin tube = pool.tubes[message.options.queue_name] code = message.to_rrepr logger.info "#{self.class.name} submitting '#{code}' to tube '#{message.options.queue_name}'" tube.put(message.to_hash.to_json, pri: message.options.priority, delay: message.options.delay, ttr: message.options.time_to_run) rescue Exception => ex logger.error "Error submitting message to beanstalk: #{ex}" Ayl::Mailer.instance.deliver_message("Error submitting message to beanstalk", ex) end end end
worker()
click to toggle source
# File lib/ayl-beanstalk/engine.rb, line 47 def worker Ayl::Beanstalk::Worker.new(@host, @port) end