instance method keep_alive

Ruby on Rails 8.1.2

Since v8.1.2

Signature

keep_alive(threshold = @keepalive)

Prod any connections that have been idle for longer than the configured keepalive time. This will incidentally verify the connection is still alive, but the main purpose is to show the server (and any intermediate network hops) that we’re still here and using the connection.

Parameters

threshold opt = @keepalive
Source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 825
      def keep_alive(threshold = @keepalive)
        return if threshold.nil?

        sequential_maintenance -> c { (c.seconds_since_last_activity || 0) > c.pool_jitter(threshold) } do |conn|
          # conn.active? will cause some amount of network activity, which is all
          # we need to provide a keepalive signal.
          #
          # If it returns false, the connection is already broken; disconnect,
          # so it can be found and repaired.
          conn.disconnect! unless conn.active?
        end
      end

Defined in activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb line 825 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::ConnectionPool

Type at least 2 characters to search.

↑↓ navigate · open · esc close