module Sequel::ConnectionValidator

  1. lib/sequel/extensions/connection_validator.rb

Methods

Public Class

  1. extended

Public Instance

  1. connection_validation_timeout

Attributes

connection_validation_timeout [RW]

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).

Public Class methods

extended(pool)

Initialize the data structures used by this extension.

[show source]
   # File lib/sequel/extensions/connection_validator.rb
63 def self.extended(pool)
64   case pool.pool_type
65   when :single, :sharded_single
66     raise Error, "cannot load connection_validator extension if using single or sharded_single connection pool"
67   end
68 
69   pool.instance_exec do
70     sync do
71       @connection_timestamps ||= {}
72       @connection_validation_timeout ||= 3600
73     end
74   end
75 
76   # Make sure the valid connection SQL query is precached,
77   # otherwise it's possible it will happen at runtime. While
78   # it should work correctly at runtime, it's better to avoid
79   # the possibility of failure altogether.
80   pool.db.send(:valid_connection_sql)
81 end