Class: UberTask::RetryInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/uber_task/retry_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_retries: nil, default_retry_wait: nil, retries: nil) ⇒ RetryInfo

Returns a new instance of RetryInfo.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/uber_task/retry_info.rb', line 13

def initialize(
  default_retries: nil,
  default_retry_wait: nil,
  retries: nil
)
  @default_retries = default_retries || 0
  @default_retry_wait = default_retry_wait || 0
  @report = true
  @retries = retries || 0
  @retries_remaining = retries || 0
  @wait = 0
end

Instance Attribute Details

#default_retriesObject (readonly)

Returns the value of attribute default_retries.



9
10
11
# File 'lib/uber_task/retry_info.rb', line 9

def default_retries
  @default_retries
end

#default_retry_waitObject (readonly)

Returns the value of attribute default_retry_wait.



9
10
11
# File 'lib/uber_task/retry_info.rb', line 9

def default_retry_wait
  @default_retry_wait
end

#reportObject

Returns the value of attribute report.



5
6
7
# File 'lib/uber_task/retry_info.rb', line 5

def report
  @report
end

#retriesObject (readonly)

Returns the value of attribute retries.



9
10
11
# File 'lib/uber_task/retry_info.rb', line 9

def retries
  @retries
end

#retries_remainingObject

Returns the value of attribute retries_remaining.



5
6
7
# File 'lib/uber_task/retry_info.rb', line 5

def retries_remaining
  @retries_remaining
end

#waitObject

Returns the value of attribute wait.



5
6
7
# File 'lib/uber_task/retry_info.rb', line 5

def wait
  @wait
end

Instance Method Details

#message(wait: nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/uber_task/retry_info.rb', line 26

def message(wait: nil)
  if wait.nil?
    wait = @wait
  end

  if wait < 1
    wait = default_retry_wait || 0
  end

  if wait.positive?
    "      Retrying in \#{wait} seconds... (\#{retries_remaining} retries remaining)\n    MSG\n  else\n    <<~MSG.strip\n      Retrying... (\#{retries_remaining} retries remaining)\n    MSG\n  end\nend\n".strip