Class: ThrottleMachines::Storage::Null

Inherits:
Base
  • Object
show all
Defined in:
lib/throttle_machines/storage/null.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #with_timeout

Constructor Details

This class inherits a constructor from ThrottleMachines::Storage::Base

Instance Method Details

#check_gcra_limit(_key, _emission_interval, _delay_tolerance, _ttl) ⇒ Object

GCRA operations



24
25
26
27
28
29
30
# File 'lib/throttle_machines/storage/null.rb', line 24

def check_gcra_limit(_key, _emission_interval, _delay_tolerance, _ttl)
  {
    allowed: true,
    retry_after: 0,
    tat: 0
  }
end

#check_token_bucket(_key, capacity, _refill_rate, _ttl) ⇒ Object

Token bucket operations



41
42
43
44
45
46
47
# File 'lib/throttle_machines/storage/null.rb', line 41

def check_token_bucket(_key, capacity, _refill_rate, _ttl)
  {
    allowed: true,
    retry_after: 0,
    tokens_remaining: capacity
  }
end

#clear(_pattern = nil) ⇒ Object

Utility operations



58
59
60
# File 'lib/throttle_machines/storage/null.rb', line 58

def clear(_pattern = nil)
  true
end

#get_counter(_key, _window) ⇒ Object



11
12
13
# File 'lib/throttle_machines/storage/null.rb', line 11

def get_counter(_key, _window)
  0
end

#get_counter_ttl(_key, _window) ⇒ Object



15
16
17
# File 'lib/throttle_machines/storage/null.rb', line 15

def get_counter_ttl(_key, _window)
  0
end

#healthy?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/throttle_machines/storage/null.rb', line 62

def healthy?
  true
end

#increment_counter(_key, _window, _amount = 1) ⇒ Object

Rate limiting operations



7
8
9
# File 'lib/throttle_machines/storage/null.rb', line 7

def increment_counter(_key, _window, _amount = 1)
  0
end

#peek_gcra_limit(_key, _emission_interval, _delay_tolerance) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/throttle_machines/storage/null.rb', line 32

def peek_gcra_limit(_key, _emission_interval, _delay_tolerance)
  {
    allowed: true,
    retry_after: 0,
    tat: 0
  }
end

#peek_token_bucket(_key, capacity, _refill_rate) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/throttle_machines/storage/null.rb', line 49

def peek_token_bucket(_key, capacity, _refill_rate)
  {
    allowed: true,
    retry_after: 0,
    tokens_remaining: capacity
  }
end

#reset_counter(_key, _window) ⇒ Object



19
20
21
# File 'lib/throttle_machines/storage/null.rb', line 19

def reset_counter(_key, _window)
  true
end