Class: Sidekiq::TransactionGuard::Middleware

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

Overview

Sidekiq client middleware that will warn/error when workers are called inside of a database transaction.

This middleware can read `sidekiq_options` set on the worker for `:transaction_guard` and `:notify_in_transaction` which will override the default behavior set in `Sidekiq::TransactionGuard.mode` and `Sidekiq::TransactionGuard.notify` respectively.

Instance Method Summary collapse

Instance Method Details

#call(worker_class, job, queue, redis_pool) ⇒ Object


13
14
15
16
17
18
# File 'lib/sidekiq/transaction_guard/middleware.rb', line 13

def call(worker_class, job, queue, redis_pool)
  # Check if we need to log this. Also, convert worker_class to its actual class
  log_transaction(worker_class.constantize, job) if in_transaction?

  yield
end