Sha256: 9bde62cd29bcd1159c2d63d9db2a75e92c391d8ac835278e9feae48a766146ab
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'rlimiter/version' # It is important that the files are loaded in the order specified below because of # inheritance dependencies. %w[/rlimiter/client.rb /rlimiter/invalid_client_error.rb /rlimiter/version.rb /rlimiter/redis_client.rb].each do |file| Dir.glob(File.dirname(File.absolute_path(__FILE__)) + file, &method(:require)) end # Module which is single-instantiated in the application via :init. module Rlimiter class << self # At the moment only redis client is supported. CLIENTS = %w[redis].freeze attr_reader :client # One time initializes the client which is to be used throughout the # application. The value of params variable will change depending on the # storage client to be initialized. # # @param [Hash] params # @return [Rlimiter::Client] def init(params) case params[:client] when 'redis' @client = RedisClient.new(params) else raise InvalidClientError, "Valid clients are #{CLIENTS.join(',')}" end end # Note : Params for the below methods are kept arbitrary for free # implementation and are specific to a single client, after usage feedback # it will be refactored to pertain to a single signature. # Register a hit to the client. def limit(*params) client.limit(*params) end # Returns when the next hit will be accepted def next_in(*params) client.next_in(*params) end # Returns the current hit count. def current_count(*params) client.current_count(*params) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rlimiter-1.0.5 | lib/rlimiter.rb |