Class: ThrottledJsonRpcClient::Eth
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ThrottledJsonRpcClient::Eth
- Defined in:
- lib/throttled_json_rpc_client/eth.rb
Instance Method Summary collapse
-
#initialize(url, rate: 5, interval: 1, redis_urls: ["redis://localhost:6379/2"], logger: Logger.new($stdout, level: :info)) ⇒ Eth
constructor
limit: #rate requests / #interval seconds.
- #method_missing(*args, **kwargs, &block) ⇒ Object
Constructor Details
#initialize(url, rate: 5, interval: 1, redis_urls: ["redis://localhost:6379/2"], logger: Logger.new($stdout, level: :info)) ⇒ Eth
limit: #rate requests / #interval seconds
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/throttled_json_rpc_client/eth.rb', line 6 def initialize( url, rate: 5, interval: 1, redis_urls: ["redis://localhost:6379/2"], logger: Logger.new($stdout, level: :info) ) @queue = DistributedRateQueue.new( redis_urls: redis_urls, key: "key:#{url}", rate: rate, interval: interval ) super(JsonRpcClient::Eth.new(url, logger: logger)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, **kwargs, &block) ⇒ Object
21 22 23 24 25 |
# File 'lib/throttled_json_rpc_client/eth.rb', line 21 def method_missing(*args, **kwargs, &block) @queue.shift do super end end |