Class: Lhm::Throttler::ReplicaLag

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

Direct Known Subclasses

SlaveLag

Constant Summary collapse

INITIAL_TIMEOUT =
0.1
DEFAULT_STRIDE =
2_000
DEFAULT_MAX_ALLOWED_LAG =
10
MAX_TIMEOUT =
INITIAL_TIMEOUT * 1024

Constants included from BackoffReduction

BackoffReduction::DEFAULT_BACKOFF_REDUCTION_FACTOR, BackoffReduction::MIN_STRIDE_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BackoffReduction

#backoff_stride

Methods included from Command

#run

Constructor Details

#initialize(options = {}) ⇒ ReplicaLag

Returns a new instance of ReplicaLag.



26
27
28
29
30
31
32
33
34
35
# File 'lib/lhm/throttler/replica_lag.rb', line 26

def initialize(options = {})
  @timeout_seconds = INITIAL_TIMEOUT
  @stride = options[:stride] || DEFAULT_STRIDE
  @allowed_lag = options[:allowed_lag] || DEFAULT_MAX_ALLOWED_LAG
  @replicas = {}
  @get_config = options[:current_config]
  @check_only = options[:check_only]

  super
end

Instance Attribute Details

#allowed_lagObject

Returns the value of attribute allowed_lag.



24
25
26
# File 'lib/lhm/throttler/replica_lag.rb', line 24

def allowed_lag
  @allowed_lag
end

#connectionObject

Returns the value of attribute connection.



24
25
26
# File 'lib/lhm/throttler/replica_lag.rb', line 24

def connection
  @connection
end

#strideObject

Returns the value of attribute stride.



24
25
26
# File 'lib/lhm/throttler/replica_lag.rb', line 24

def stride
  @stride
end

#timeout_secondsObject

Returns the value of attribute timeout_seconds.



24
25
26
# File 'lib/lhm/throttler/replica_lag.rb', line 24

def timeout_seconds
  @timeout_seconds
end

Instance Method Details

#executeObject



37
38
39
# File 'lib/lhm/throttler/replica_lag.rb', line 37

def execute
  sleep(throttle_seconds)
end