Class: Fluent::PluginHelper::RetryState::ExponentialBackOffRetry

Inherits:
RetryStateMachine show all
Defined in:
lib/fluent/plugin_helper/retry_state.rb

Instance Attribute Summary

Attributes inherited from RetryStateMachine

#current, #next_time, #secondary_transition_at, #secondary_transition_steps, #start, #steps, #timeout_at, #title

Instance Method Summary collapse

Methods inherited from RetryStateMachine

#calc_next_time, #current_time, #limit?, #randomize, #secondary?, #step

Constructor Details

#initialize(title, wait, timeout, forever, max_steps, randomize, randomize_width, backoff_base, max_interval, secondary, secondary_threathold) ⇒ ExponentialBackOffRetry

Returns a new instance of ExponentialBackOffRetry.



139
140
141
142
143
144
145
146
# File 'lib/fluent/plugin_helper/retry_state.rb', line 139

def initialize(title, wait, timeout, forever, max_steps, randomize, randomize_width, backoff_base, max_interval, secondary, secondary_threathold)
  super(title, wait, timeout, forever, max_steps, randomize, randomize_width, secondary, secondary_threathold)
  @constant_factor = wait
  @backoff_base = backoff_base
  @max_interval = max_interval

  @next_time = @start + @constant_factor
end

Instance Method Details

#naive_next_time(retry_next_times) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/fluent/plugin_helper/retry_state.rb', line 148

def naive_next_time(retry_next_times)
  # make it infinite if calculated "interval" is too big
  interval = @constant_factor.to_f * ( @backoff_base ** ( retry_next_times - 1 ) )
  intr = if interval.finite?
           if @max_interval && interval > @max_interval
             @max_interval
           else
             interval
           end
         else
           interval
         end
  current_time + randomize(intr)
end