Module: Sequel::ConnectionExpiration

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

Defined Under Namespace

Classes: Retry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#connection_expiration_random_delayObject

The maximum number of seconds that will be added as a random delay to the expiration timeout Defaults to 0 seconds (no random delay).



44
45
46
# File 'lib/sequel/extensions/connection_expiration.rb', line 44

def connection_expiration_random_delay
  @connection_expiration_random_delay
end

#connection_expiration_timeoutObject

The number of seconds that need to pass since connection creation before expiring a connection. Defaults to 14400 seconds (4 hours).



40
41
42
# File 'lib/sequel/extensions/connection_expiration.rb', line 40

def connection_expiration_timeout
  @connection_expiration_timeout
end

Class Method Details

.extended(pool) ⇒ Object

Initialize the data structures used by this extension.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sequel/extensions/connection_expiration.rb', line 47

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

  pool.instance_exec do
    sync do
      @connection_expiration_timestamps ||= {}
      @connection_expiration_timeout ||= 14400
      @connection_expiration_random_delay ||= 0
    end
  end
end