Sha256: 12637e16fc4f9ea99d9d6aaad736b5a346c13134cdbe2bfffd4ceda8cf703d14

Contents?: true

Size: 1019 Bytes

Versions: 2

Compression:

Stored size: 1019 Bytes

Contents

require 'bearcat/version'
require 'bearcat/client'

module Bearcat
  class << self
    require 'logger'
    attr_accessor :master_rate_limit
    attr_writer :rate_limit_min, :rate_limits, :max_sleep_seconds,
                :min_sleep_seconds, :logger, :rate_limiter

    def configure
      yield self if block_given?
    end

    def rate_limiter
      @rate_limiter
    end

    def rate_limit_min
      @rate_limit_min ||= 175
    end

    def min_sleep_seconds
      @min_sleep_seconds ||= 5
    end

    def max_sleep_seconds
      @max_sleep_seconds ||= 60
    end

    def logger
      return @logger if defined? @logger
      @logger = Logger.new(STDOUT)
      @logger.level = Logger::DEBUG
      @logger
    end

    def redis_pool
      require 'bearcat/redis_connection'
      @redis_pool ||= RedisConnection.create(env_prefix: "BEARCAT")
    end

    def redis
      raise ArgumentError, "requires a block" unless block_given?
      redis_pool.with do |conn|
        yield conn
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bearcat-1.5.20 lib/bearcat.rb
bearcat-1.5.19 lib/bearcat.rb