Module: ActiveRecord::DynamicTimeout::TimeoutAdapterExtension

Defined in:
lib/active_record/dynamic_timeout/extensions/abstract_adapter_extension.rb

Instance Method Summary collapse

Instance Method Details

#configure_connectionObject

This ensures new connections from reconnects have the correct timeout.



52
53
54
55
56
57
# File 'lib/active_record/dynamic_timeout/extensions/abstract_adapter_extension.rb', line 52

def configure_connection
  super
  if supports_dynamic_timeouts? && active_record_dynamic_timeout
    set_connection_timeout(@raw_connection, active_record_dynamic_timeout)
  end
end

#reset_dynamic_timeout_for_checkinObject



59
60
61
62
63
64
65
# File 'lib/active_record/dynamic_timeout/extensions/abstract_adapter_extension.rb', line 59

def reset_dynamic_timeout_for_checkin
  if active_record_dynamic_timeout
    with_raw_connection do |conn|
      reset_dynamic_timeout(conn)
    end
  end
end

#with_raw_connection(*args, **kwargs, &block) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/active_record/dynamic_timeout/extensions/abstract_adapter_extension.rb', line 40

def with_raw_connection(*args, **kwargs, &block)
  super do |raw_connection|
    set_dynamic_timeout(raw_connection, ActiveRecord::Base.current_timeout_seconds)
    yield raw_connection
  ensure
    if timeout_set_client_side?
      reset_dynamic_timeout(raw_connection)
    end
  end
end