Class: PgFailover::ConnectionValidator
- Inherits:
-
Object
- Object
- PgFailover::ConnectionValidator
- Defined in:
- lib/pg_failover/connection_validator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
-
#throttle ⇒ Object
readonly
Returns the value of attribute throttle.
-
#throttle_interval ⇒ Object
readonly
Returns the value of attribute throttle_interval.
Instance Method Summary collapse
- #call(in_recovery:, reconnect:, throttle_by:) ⇒ Object
-
#initialize(config) ⇒ ConnectionValidator
constructor
A new instance of ConnectionValidator.
Constructor Details
#initialize(config) ⇒ ConnectionValidator
Returns a new instance of ConnectionValidator.
5 6 7 8 9 10 |
# File 'lib/pg_failover/connection_validator.rb', line 5 def initialize(config) @logger = config.logger @max_retries = config.max_retries @throttle = Throttle.new(throttle_interval: config.throttle_interval) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/pg_failover/connection_validator.rb', line 12 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/pg_failover/connection_validator.rb', line 12 def logger @logger end |
#max_retries ⇒ Object (readonly)
Returns the value of attribute max_retries.
12 13 14 |
# File 'lib/pg_failover/connection_validator.rb', line 12 def max_retries @max_retries end |
#throttle ⇒ Object (readonly)
Returns the value of attribute throttle.
12 13 14 |
# File 'lib/pg_failover/connection_validator.rb', line 12 def throttle @throttle end |
#throttle_interval ⇒ Object (readonly)
Returns the value of attribute throttle_interval.
12 13 14 |
# File 'lib/pg_failover/connection_validator.rb', line 12 def throttle_interval @throttle_interval end |
Instance Method Details
#call(in_recovery:, reconnect:, throttle_by:) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/pg_failover/connection_validator.rb', line 14 def call(in_recovery:, reconnect:, throttle_by:) if config.throttle_enabled? throttle.on_stale(throttle_by) { check_and_reconnect(in_recovery, reconnect) } else check_and_reconnect(in_recovery, reconnect) end end |