Class: Droonga::Client::RateLimiter
- Inherits:
-
Object
- Object
- Droonga::Client::RateLimiter
- Defined in:
- lib/droonga/client/rate-limiter.rb
Constant Summary collapse
- NO_LIMIT =
-1
Instance Method Summary collapse
-
#initialize(client, messages_per_second) ⇒ RateLimiter
constructor
A new instance of RateLimiter.
- #method_missing(name, *args, &block) ⇒ Object
- #send(*args, &block) ⇒ Object
Constructor Details
#initialize(client, messages_per_second) ⇒ RateLimiter
Returns a new instance of RateLimiter.
21 22 23 24 25 |
# File 'lib/droonga/client/rate-limiter.rb', line 21 def initialize(client, ) @client = client @messages_per_second = @diff_in_seconds_per_message = 1.0 / @messages_per_second end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/droonga/client/rate-limiter.rb', line 33 def method_missing(name, *args, &block) if @client.respond_to?(name) @client.__send__(name, *args, &block) else super end end |
Instance Method Details
#send(*args, &block) ⇒ Object
27 28 29 30 31 |
# File 'lib/droonga/client/rate-limiter.rb', line 27 def send(*args, &block) limit do @client.send(*args, &block) end end |