Sha256: 8f2faa19e2a96ad3f4696e5b47aff19e1fb08ad19796645d929a7295be6dc865

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

require 'redis'

module RedisProxy
  extend self

  def method_missing method, *args
    tries = 0
    begin
      redis.send method, *args
    rescue Redis::TimeoutError, Redis::CannotConnectError
      if (tries += 1) < 10
        logger.warn '[RedisProxy] Retry a Redis call'
        retry
      else
        logger.warn '[RedisProxy] Fail a Redis call after 10 tries'
        raise
      end
    end
  end

  private

  def redis
    @redis ||= AirbrakeProxy.configuration.redis
  end

  def logger
    @logger ||= AirbrakeProxy.configuration.logger
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
airbrake_proxy-0.1.2 lib/airbrake_proxy/redis_proxy.rb
airbrake_proxy-0.1.1 lib/airbrake_proxy/redis_proxy.rb