Sha256: f352ee0c4013d6e6952d055325e761cab294a027cec3cab9faf87450a25dbb1a

Contents?: true

Size: 488 Bytes

Versions: 1

Compression:

Stored size: 488 Bytes

Contents

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
        Rails.logger.warn '[RedisProxy] Retry a Redis call'
        retry
      else
        Rails.logger.warn '[RedisProxy] Fail a Redis call after 10 tries'
        raise
      end
    end
  end

  private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
airbrake_proxy-0.1.0 lib/airbrake_proxy/redis_proxy.rb