Method: Sequel::ConnectionValidator.extended

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

.extended(pool) ⇒ Object

Initialize the data structures used by this extension.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/sequel/extensions/connection_validator.rb', line 63

def self.extended(pool)
  case pool.pool_type
  when :single, :sharded_single
    raise Error, "cannot load connection_validator extension if using single or sharded_single connection pool"
  end

  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