Sha256: f70338085fadd01722b65f8d87a811adc25b37aa22f55e87e544c7f590139231
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
module Cassanity module RetryStrategies class RetryStrategy # Internal: override in subclass. # # attempts - how many times the unsuccessful call has been tried so far # last_error - the error raised by the unsuccessful call def fail(attempts, last_error) raise 'not implemented' end # Public: execute the given block, and handle errors raised # by the Cql::Client driver. Call the retry method (overridden in your # subclass) on each failed attempt with a current retry count and # the error raised by the block. # # payload - A Hash from an instrumenter to store a retry count in, or nil if # the number of retries shouldn't be tracked. def execute(payload = nil) return unless block_given? attempt = 0 while attempt += 1 begin payload[:attempts] = attempt unless payload.nil? return yield rescue ::Cql::CqlError => e fail(attempt, e) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems