module RdsRotateDbSnapshots::ActionWrappers

Public Instance Methods

with_backoff(*method_names) click to toggle source
Calls superclass method
# File lib/rds_rotate_db_snapshots/action_wrappers.rb, line 5
def with_backoff(*method_names)
  method_names.each do |m|
    wrapper = Module.new do
      define_method(m) do |*args|
        reset_backoff
        begin
          super(*args)
        rescue Aws::RDS::Errors::ServiceError => e
          raise if e.is_a? Aws::RDS::Errors::ExpiredToken

          # TODO: re-work
          puts "Error: #{e}"
          backoff
          retry
        end
      end
    end
    prepend wrapper
  end
end