Sha256: 2cc589945c34b90fc97a79443280e54d12b73d14e5c1d3cbbaa71a3a7f9d35d8
Contents?: true
Size: 1.23 KB
Versions: 29
Compression:
Stored size: 1.23 KB
Contents
module ForemanRhCloud module Async module ExponentialBackoff extend ActiveSupport::Concern include Dynflow::Action::Polling # Use each interval once def attempts_before_next_interval 1 end # define poll intervals in the following way: [1/10..1, 1..10, 10..100] e.t.c. # total count of intervals would be the amount of poll retries. def poll_intervals (1..poll_max_retries).map do |i| base = 10**i random_interval(base) end end def done! @done = true end def done? @done end def invoke_external_task # Call the polling method from task's framework poll_external_task_with_rescue # supress unexpected task output serialization {} end def poll_external_task try_execute # supress unexpected task output serialization {} end # override this method in the consumng class # This is the action that we expect to retry in case of an exception. def try_execute raise NotImplementedError end private def random_interval(base) Random.new.rand(base..10 * base) end end end end
Version data entries
29 entries across 29 versions & 1 rubygems