Class: Middleware::Sidekiq::ActiveRecordConnectionPool

Inherits:
Object
  • Object
show all
Defined in:
lib/middleware/sidekiq/active_record_connection_pool.rb

Overview

Sidekiq middleware to clear the ActiveRecord connection pool after each job.

Instance Method Summary collapse

Instance Method Details

#callObject

Allows the job to be processed, then clears the ActiveRecord connection pool.



35
36
37
38
39
40
41
42
43
# File 'lib/middleware/sidekiq/active_record_connection_pool.rb', line 35

def call(*)
  yield
ensure
  begin
    ActiveRecord::Base.connection_handler.clear_active_connections!
  rescue => error
    warn error.message
  end
end