Class: RockQueue::QueueObject
- Inherits:
-
Object
- Object
- RockQueue::QueueObject
- Defined in:
- lib/rock-queue/queue_object.rb
Overview
Queue object wrapper
Constant Summary collapse
- DEFAULT_FAIL_LIMIT =
3
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#fails ⇒ Object
readonly
Returns the value of attribute fails.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#add_fail(exception) ⇒ Object
Add processing fail.
-
#get_sleep_time ⇒ Object
Get sleep time after fail.
-
#initialize(object, args) ⇒ QueueObject
constructor
Constructor of queue objects wrapper.
Constructor Details
#initialize(object, args) ⇒ QueueObject
Constructor of queue objects wrapper
11 12 13 14 15 |
# File 'lib/rock-queue/queue_object.rb', line 11 def initialize(object, args) @object = object @args = args @fails = Array.new end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/rock-queue/queue_object.rb', line 8 def args @args end |
#fails ⇒ Object (readonly)
Returns the value of attribute fails.
8 9 10 |
# File 'lib/rock-queue/queue_object.rb', line 8 def fails @fails end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/rock-queue/queue_object.rb', line 8 def object @object end |
Instance Method Details
#add_fail(exception) ⇒ Object
Add processing fail
18 19 20 21 22 23 24 25 |
# File 'lib/rock-queue/queue_object.rb', line 18 def add_fail(exception) @fails << exception if @fails.length < DEFAULT_FAIL_LIMIT return true else RockQueue::Notifiers.instance.notify(exception) end end |
#get_sleep_time ⇒ Object
Get sleep time after fail
28 29 30 |
# File 'lib/rock-queue/queue_object.rb', line 28 def get_sleep_time 2 ** @fails.length end |