Module: Sequel::ConnectionValidator

Defined in:
lib/sequel/extensions/connection_validator.rb

Defined Under Namespace

Classes: Retry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#connection_validation_timeoutObject

The number of seconds that need to pass since connection checkin before attempting to validate the connection when checking it out from the pool. Defaults to 3600 seconds (1 hour).


59
60
61
# File 'lib/sequel/extensions/connection_validator.rb', line 59

def connection_validation_timeout
  @connection_validation_timeout
end

Class Method Details

.extended(pool) ⇒ Object

Initialize the data structures used by this extension.


62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/sequel/extensions/connection_validator.rb', line 62

def self.extended(pool)
  pool.instance_exec do
    sync do
      @connection_timestamps ||= {}
      @connection_validation_timeout ||= 3600
    end
  end

  # Make sure the valid connection SQL query is precached,
  # otherwise it's possible it will happen at runtime. While
  # it should work correctly at runtime, it's better to avoid
  # the possibility of failure altogether.
  pool.db.send(:valid_connection_sql)
end