Class: Lhm::Throttler::ReplicaLag

Inherits:
Object
  • Object
show all
Includes:
Command
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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Command

#run

Constructor Details

#initialize(options = {}) ⇒ ReplicaLag

Returns a new instance of ReplicaLag.



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

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]
end

Instance Attribute Details

#allowed_lagObject

Returns the value of attribute allowed_lag.



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

def allowed_lag
  @allowed_lag
end

#connectionObject

Returns the value of attribute connection.



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

def connection
  @connection
end

#strideObject

Returns the value of attribute stride.



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

def stride
  @stride
end

#timeout_secondsObject

Returns the value of attribute timeout_seconds.



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

def timeout_seconds
  @timeout_seconds
end

Instance Method Details

#executeObject



34
35
36
# File 'lib/lhm/throttler/replica_lag.rb', line 34

def execute
  sleep(throttle_seconds)
end