Class: ThrottleMachines::Storage::Base
- Inherits:
-
Object
- Object
- ThrottleMachines::Storage::Base
- Defined in:
- lib/throttle_machines/storage/base.rb
Instance Method Summary collapse
-
#check_gcra_limit(key, emission_interval, delay_tolerance, ttl) ⇒ Object
GCRA operations (atomic).
-
#check_token_bucket(key, capacity, refill_rate, ttl) ⇒ Object
Token bucket operations (atomic).
-
#clear(pattern = nil) ⇒ Object
Utility operations.
- #get_counter(key, window) ⇒ Object
- #get_counter_ttl(key, window) ⇒ Object
- #healthy? ⇒ Boolean
-
#increment_counter(key, window, amount = 1) ⇒ Object
Rate limiting operations.
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #peek_gcra_limit(key, emission_interval, delay_tolerance) ⇒ Object
- #peek_token_bucket(key, capacity, refill_rate) ⇒ Object
- #reset_counter(key, window) ⇒ Object
- #with_timeout(timeout, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/throttle_machines/storage/base.rb', line 6 def initialize( = {}) @options = end |
Instance Method Details
#check_gcra_limit(key, emission_interval, delay_tolerance, ttl) ⇒ Object
GCRA operations (atomic)
28 29 30 |
# File 'lib/throttle_machines/storage/base.rb', line 28 def check_gcra_limit(key, emission_interval, delay_tolerance, ttl) raise NotImplementedError end |
#check_token_bucket(key, capacity, refill_rate, ttl) ⇒ Object
Token bucket operations (atomic)
37 38 39 |
# File 'lib/throttle_machines/storage/base.rb', line 37 def check_token_bucket(key, capacity, refill_rate, ttl) raise NotImplementedError end |
#clear(pattern = nil) ⇒ Object
Utility operations
46 47 48 |
# File 'lib/throttle_machines/storage/base.rb', line 46 def clear(pattern = nil) raise NotImplementedError end |
#get_counter(key, window) ⇒ Object
15 16 17 |
# File 'lib/throttle_machines/storage/base.rb', line 15 def get_counter(key, window) raise NotImplementedError end |
#get_counter_ttl(key, window) ⇒ Object
19 20 21 |
# File 'lib/throttle_machines/storage/base.rb', line 19 def get_counter_ttl(key, window) raise NotImplementedError end |
#healthy? ⇒ Boolean
50 51 52 |
# File 'lib/throttle_machines/storage/base.rb', line 50 def healthy? raise NotImplementedError end |
#increment_counter(key, window, amount = 1) ⇒ Object
Rate limiting operations
11 12 13 |
# File 'lib/throttle_machines/storage/base.rb', line 11 def increment_counter(key, window, amount = 1) raise NotImplementedError end |
#peek_gcra_limit(key, emission_interval, delay_tolerance) ⇒ Object
32 33 34 |
# File 'lib/throttle_machines/storage/base.rb', line 32 def peek_gcra_limit(key, emission_interval, delay_tolerance) raise NotImplementedError end |
#peek_token_bucket(key, capacity, refill_rate) ⇒ Object
41 42 43 |
# File 'lib/throttle_machines/storage/base.rb', line 41 def peek_token_bucket(key, capacity, refill_rate) raise NotImplementedError end |
#reset_counter(key, window) ⇒ Object
23 24 25 |
# File 'lib/throttle_machines/storage/base.rb', line 23 def reset_counter(key, window) raise NotImplementedError end |
#with_timeout(timeout, &block) ⇒ Object
54 55 56 57 58 |
# File 'lib/throttle_machines/storage/base.rb', line 54 def with_timeout(timeout, &block) Timeout.timeout(timeout, &block) rescue Timeout::Error nil end |