Class: RockQueue::QueueObject

Inherits:
Object
  • Object
show all
Defined in:
lib/rock-queue/queue_object.rb

Overview

Queue object wrapper

Constant Summary collapse

DEFAULT_FAIL_LIMIT =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argsObject (readonly)

Returns the value of attribute args.



8
9
10
# File 'lib/rock-queue/queue_object.rb', line 8

def args
  @args
end

#failsObject (readonly)

Returns the value of attribute fails.



8
9
10
# File 'lib/rock-queue/queue_object.rb', line 8

def fails
  @fails
end

#objectObject (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_timeObject

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