Class: Lhm::Throttler::SlaveLag

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

Constant Summary collapse

INITIAL_TIMEOUT =
0.1
DEFAULT_STRIDE =
40_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 = {}) ⇒ SlaveLag

Returns a new instance of SlaveLag


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

def initialize(options = {})
  @timeout_seconds = INITIAL_TIMEOUT
  @stride = options[:stride] || DEFAULT_STRIDE
  @allowed_lag = options[:allowed_lag] || DEFAULT_MAX_ALLOWED_LAG
  @slave_connections = {}
end

Instance Attribute Details

#allowed_lagObject

Returns the value of attribute allowed_lag


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

def allowed_lag
  @allowed_lag
end

#connectionObject

Returns the value of attribute connection


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

def connection
  @connection
end

#strideObject

Returns the value of attribute stride


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

def stride
  @stride
end

#timeout_secondsObject

Returns the value of attribute timeout_seconds


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

def timeout_seconds
  @timeout_seconds
end

Instance Method Details

#executeObject


21
22
23
# File 'lib/lhm/throttler/slave_lag.rb', line 21

def execute
  sleep(throttle_seconds)
end