Hello all,

I'm adding the :connection_expiration extension to a DB instance, but I 
need to change its default expiration time with, for example:
DB.pool.connection_expiration_timeout = 100

However, this new expiration time is not applied to the initial connection, 
but rather the default value of 14400, and I'm having to resort to manually 
disconnecting and reconnecting:

*DB = Sequel.connect(*
*  adapter: 'mysql2', host: '127.0.0.1', port: '49153', database: 'my_db',*
*  user: 'root', password: 'my_pass',*

*  ssl_mode: :disabled,*
*  extensions: :connection_expiration,*

*)*

*def expiration_times(db)*
*  
db.pool.instance_variable_get(:@connection_expiration_timestamps).values.map{|v|
 
v[1]}.join(', ')*
*end*

*DB.pool.connection_expiration_timeout = 100*
*print "Initial values: "*
*puts expiration_times(DB)*

*DB.disconnect*
*print "After disconnect: "*
*puts expiration_times(DB)*

*DB[:users].first*
*print "After reconnect: "*
*puts expiration_times(DB)*

*# => Initial values: 14400.0*
*# => After disconnect: *
*# => After reconnect: 100.0*

That's still passable, but if I additionally want to enable :preconnect, 
this doesn't work at all, since after DB.disconnect, I'd have to call the 
private method `preconnect` directly.

*DB = Sequel.connect(*
*  adapter: 'mysql2', host: '127.0.0.1', port: '49153', database: 'my_db',*
*  user: 'root', password: 'my_pass',*

*  ssl_mode: :disabled,*
*  preconnect_extensions: :connection_expiration,*
*  preconnect: true*
*)*


My specific use case is with the connection_expiration extension, but I'm 
interested if there's in general a way to configure the extension prior to 
a connection being established, and especially for preconnections.

Thanks in advance,

PS to Jeremy: The Polished Ruby book you wrote is fantastic. Congrats!


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/daddf7c9-e3e4-4756-9d3f-555780b58c4fn%40googlegroups.com.

Reply via email to