Class: SidekiqTransactionGuard::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 `SidekiqTransactionGuard.mode` and `SidekiqTransactionGuard.notify` respectively.

Instance Method Summary collapse

Instance Method Details

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


12
13
14
15
16
17
# File 'lib/sidekiq_transaction_guard/middleware.rb', line 12

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