Class: ActiveMessaging::Worker
- Inherits:
-
Object
- Object
- ActiveMessaging::Worker
- Includes:
- Celluloid
- Defined in:
- lib/activemessaging/threaded_poller.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#poller ⇒ Object
Returns the value of attribute poller.
Instance Method Summary collapse
- #execute(message) ⇒ Object
-
#initialize(poller, options) ⇒ Worker
constructor
A new instance of Worker.
- #inspect ⇒ Object
- #logger ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(poller, options) ⇒ Worker
Returns a new instance of Worker.
203 204 205 206 |
# File 'lib/activemessaging/threaded_poller.rb', line 203 def initialize(poller, ) self.poller = poller self. = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
201 202 203 |
# File 'lib/activemessaging/threaded_poller.rb', line 201 def @options end |
#poller ⇒ Object
Returns the value of attribute poller.
201 202 203 |
# File 'lib/activemessaging/threaded_poller.rb', line 201 def poller @poller end |
Instance Method Details
#execute(message) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/activemessaging/threaded_poller.rb', line 208 def execute() begin ::ActiveMessaging::Gateway.dispatch() rescue Object => err logger.error("ActiveMessaging::Worker.execute error - #{err.inspect}") abort(err) ensure ::ActiveRecord::Base.clear_active_connections! if defined?(::ActiveRecord) end poller.executed!(current_actor) end |
#inspect ⇒ Object
221 222 223 |
# File 'lib/activemessaging/threaded_poller.rb', line 221 def inspect "#<Worker #{to_s}>" end |
#logger ⇒ Object
229 |
# File 'lib/activemessaging/threaded_poller.rb', line 229 def logger; ::ActiveMessaging.logger; end |
#to_s ⇒ Object
225 226 227 |
# File 'lib/activemessaging/threaded_poller.rb', line 225 def to_s @str ||= "#{Process.pid}-#{Thread.current.object_id}:#{self.object_id}" end |