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.

Returns:

  • (Integer)

    the current attempt number (1 for the first run)



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.

Returns:

  • (Integer)

    the number of retries (0 on first run, 1+ on retries)



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.

Returns:

  • (Boolean)

    true if this is a retry, false if this is the first run



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.

Returns:

  • (Boolean)

    true if a failure will schedule another attempt, false otherwise



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