Class: ThrottleMachines::Storage::Base

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

Direct Known Subclasses

Memory, Null, Redis

Instance Method Summary collapse

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 = {})
  @options = options
end

Instance Method Details

#check_gcra_limit(key, emission_interval, delay_tolerance, ttl) ⇒ Object

GCRA operations (atomic)

Raises:

  • (NotImplementedError)


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)

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/throttle_machines/storage/base.rb', line 46

def clear(pattern = nil)
  raise NotImplementedError
end

#get_counter(key, window) ⇒ Object

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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

def get_counter_ttl(key, window)
  raise NotImplementedError
end

#healthy?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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