Class: Lhm::Throttler::Time

Inherits:
Object
  • Object
show all
Includes:
Command, BackoffReduction
Defined in:
lib/lhm/throttler/time.rb

Direct Known Subclasses

LegacyTime

Constant Summary collapse

DEFAULT_TIMEOUT =
0.1
DEFAULT_STRIDE =
2_000
DEFAULT_BACKOFF_REDUCTION_FACTOR =

20%

0.2
MIN_STRIDE_SIZE =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BackoffReduction

#backoff_stride

Methods included from Command

#run

Constructor Details

#initialize(options = {}) ⇒ Time

Returns a new instance of Time.



15
16
17
18
19
20
# File 'lib/lhm/throttler/time.rb', line 15

def initialize(options = {})
  @timeout_seconds = options[:delay] || DEFAULT_TIMEOUT
  @stride = options[:stride] || DEFAULT_STRIDE

  super
end

Instance Attribute Details

#strideObject

Returns the value of attribute stride.



13
14
15
# File 'lib/lhm/throttler/time.rb', line 13

def stride
  @stride
end

#timeout_secondsObject

Returns the value of attribute timeout_seconds.



12
13
14
# File 'lib/lhm/throttler/time.rb', line 12

def timeout_seconds
  @timeout_seconds
end

Instance Method Details

#executeObject



22
23
24
# File 'lib/lhm/throttler/time.rb', line 22

def execute
  sleep timeout_seconds
end