Class: Chore::UnitOfWork
- Inherits:
-
Struct
- Object
- Struct
- Chore::UnitOfWork
- Defined in:
- lib/chore/unit_of_work.rb
Overview
Simple class to hold job processing information. Has six attributes:
-
:id
The queue implementation specific identifier for this message. -
:receipt_handle
The queue implementation specific identifier for the receipt of this message. -
:queue_name
The name of the queue the job came from -
:queue_timeout
The time (in seconds) before the job will get re-enqueued if not processed -
:message
The actual data of the message. -
:previous_attempts
The number of times the work has been attempted previously. -
:consumer
The consumer instance used to fetch this message. Most queue implementations won't need access to this, but some (RabbitMQ) will. So we
make sure to pass it along with each message. This instance will be used by
the Worker for things like complete
and
</tt>reject</tt>.
Instance Attribute Summary collapse
-
#consumer ⇒ Object
Returns the value of attribute consumer.
-
#created_at ⇒ Object
The time at which this unit of work was created.
-
#decoded_message ⇒ Object
Returns the value of attribute decoded_message.
-
#id ⇒ Object
Returns the value of attribute id.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#message ⇒ Object
Returns the value of attribute message.
-
#previous_attempts ⇒ Object
Returns the value of attribute previous_attempts.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
-
#queue_timeout ⇒ Object
Returns the value of attribute queue_timeout.
-
#receipt_handle ⇒ Object
Returns the value of attribute receipt_handle.
Instance Method Summary collapse
-
#current_attempt ⇒ Object
The current attempt number for the worker processing this message.
-
#initialize ⇒ UnitOfWork
constructor
:nodoc:.
Constructor Details
#initialize ⇒ UnitOfWork
:nodoc:
16 17 18 19 |
# File 'lib/chore/unit_of_work.rb', line 16 def initialize(*) #:nodoc: super @created_at = Time.now end |
Instance Attribute Details
#consumer ⇒ Object
Returns the value of attribute consumer
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def consumer @consumer end |
#created_at ⇒ Object
The time at which this unit of work was created
14 15 16 |
# File 'lib/chore/unit_of_work.rb', line 14 def created_at @created_at end |
#decoded_message ⇒ Object
Returns the value of attribute decoded_message
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def @decoded_message end |
#id ⇒ Object
Returns the value of attribute id
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def id @id end |
#klass ⇒ Object
Returns the value of attribute klass
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def klass @klass end |
#message ⇒ Object
Returns the value of attribute message
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def @message end |
#previous_attempts ⇒ Object
Returns the value of attribute previous_attempts
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def previous_attempts @previous_attempts end |
#queue_name ⇒ Object
Returns the value of attribute queue_name
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def queue_name @queue_name end |
#queue_timeout ⇒ Object
Returns the value of attribute queue_timeout
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def queue_timeout @queue_timeout end |
#receipt_handle ⇒ Object
Returns the value of attribute receipt_handle
12 13 14 |
# File 'lib/chore/unit_of_work.rb', line 12 def receipt_handle @receipt_handle end |
Instance Method Details
#current_attempt ⇒ Object
The current attempt number for the worker processing this message.
22 23 24 |
# File 'lib/chore/unit_of_work.rb', line 22 def current_attempt previous_attempts + 1 end |