Class: SidekiqUniqueJobs::Server::Middleware

Inherits:
Object
  • Object
show all
Includes:
OptionsWithFallback
Defined in:
lib/sidekiq_unique_jobs/server/middleware.rb

Overview

The unique sidekiq middleware for the server processor

Author:

Constant Summary

Constants included from OptionsWithFallback

OptionsWithFallback::LOCKS

Instance Method Summary collapse

Methods included from OptionsWithFallback

#lock, #lock_class, #lock_type, #log_duplicate_payload?, #options, #unique_disabled?, #unique_enabled?, #unique_type

Instance Method Details

#call(worker_class, item, queue) { ... } ⇒ Object

Runs the server middleware

Used from Sidekiq::Processor#process

Parameters:

  • worker_class (Sidekiq::Worker)
  • item (Hash)

    a sidekiq job hash

  • queue (String)

    name of the queue

Yields:

  • when uniqueness is disabled

  • when the lock class executes successfully



18
19
20
21
22
23
24
25
26
27
# File 'lib/sidekiq_unique_jobs/server/middleware.rb', line 18

def call(worker_class, item, queue)
  @worker_class = worker_class
  @item         = item
  @queue        = queue
  return yield if unique_disabled?

  lock.execute do
    yield
  end
end