blob: 1ede0095f862e026fe1d3fe0e8836d26f6b2e1be (
plain) (
tree)
|
|
module ActionCable
module Server
class Worker
# Clear active connections between units of work so the long-running channel or connection processes do not hoard connections.
module ActiveRecordConnectionManagement
extend ActiveSupport::Concern
included do
if defined?(ActiveRecord::Base)
set_callback :work, :around, :with_database_connections
end
end
def with_database_connections
ActiveRecord::Base.logger.tagged(*connection.logger.tags) { yield }
ensure
ActiveRecord::Base.clear_active_connections!
end
end
end
end
end
|