module MariaDbClusterPool::ConnectTimeout
This module is mixed into connection adapters to allow the reconnect! method to timeout if the IP address becomes unreachable. The default timeout is 1 second, but you can change it by setting the connect_timeout
parameter in the adapter configuration.
Attributes
connect_timeout[RW]
Public Class Methods
included(base)
click to toggle source
# File lib/maria_db_cluster_pool/connect_timeout.rb, line 10 def self.included(base) base.alias_method_chain :reconnect!, :connect_timeout end
Public Instance Methods
reconnect_with_connect_timeout!()
click to toggle source
# File lib/maria_db_cluster_pool/connect_timeout.rb, line 14 def reconnect_with_connect_timeout! begin timeout(connect_timeout || 1) do reconnect_without_connect_timeout! end rescue Timeout::Error raise ActiveRecord::ConnectionTimeoutError.new("reconnect timed out") end end