Class: Rage::Deferred::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/deferred/metadata.rb

Overview

Provides metadata about the current deferred task execution.

Class Method Summary collapse

Class Method Details

.attemptsInteger

Returns the current attempt number.



10
11
12
# File 'lib/rage/deferred/metadata.rb', line 10

def attempts
  Rage::Deferred::Context.get_attempts(context).to_i + 1
end

.retriesInteger

Returns the number of retries that have occurred for the current task.



16
17
18
# File 'lib/rage/deferred/metadata.rb', line 16

def retries
  attempts - 1
end

.retrying?Boolean

Checks whether this is a retry execution.



22
23
24
# File 'lib/rage/deferred/metadata.rb', line 22

def retrying?
  attempts > 1
end

.will_retry?Boolean

Checks whether the task will be retried if the current execution fails.



28
29
30
31
# File 'lib/rage/deferred/metadata.rb', line 28

def will_retry?
  task = Rage::Deferred::Context.get_task(context)
  task.__should_retry?(attempts)
end