class Fluent::PluginHelper::RetryState::ExponentialBackOffRetry

Public Class Methods

new(title, wait, timeout, forever, max_steps, randomize, randomize_width, backoff_base, max_interval, secondary, secondary_threathold) click to toggle source
# 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

Public Instance Methods

naive_next_time(retry_next_times) click to toggle source
# 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