Class: Ayl::Beanstalk::Engine
- Inherits:
-
Object
- Object
- Ayl::Beanstalk::Engine
- Includes:
- Pool, Logging
- Defined in:
- lib/ayl-beanstalk/engine.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #asynchronous? ⇒ Boolean
-
#initialize(host = 'localhost', port = 11300) ⇒ Engine
constructor
A new instance of Engine.
- #is_connected? ⇒ Boolean
- #submit(message) ⇒ Object
- #worker ⇒ Object
Methods included from Pool
Constructor Details
#initialize(host = 'localhost', port = 11300) ⇒ Engine
Returns a new instance of Engine.
11 12 13 14 15 |
# 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 |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/ayl-beanstalk/engine.rb', line 9 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/ayl-beanstalk/engine.rb', line 9 def port @port end |
Instance Method Details
#asynchronous? ⇒ Boolean
17 |
# File 'lib/ayl-beanstalk/engine.rb', line 17 def asynchronous?() true end |
#is_connected? ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ayl-beanstalk/engine.rb', line 19 def is_connected? connected = true begin pool rescue ::Beanstalk::NotConnected => ex logger.error "#{self.class.name} not connected error: #{ex}" connected = false end connected end |
#submit(message) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ayl-beanstalk/engine.rb', line 30 def submit() log_call(:submit) do begin pool.use(..queue_name) code = .to_rrepr logger.info "#{self.class.name} submitting '#{code}' to tube '#{..queue_name}'" pool.yput(.to_hash, ..priority, ..delay, ..time_to_run) rescue Exception => ex logger.error "Error submitting message to beanstalk: #{ex}" end end end |