Class: SidekiqUniqueJobs::Server

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

Overview

The unique sidekiq middleware for the server processor

Author:

Constant Summary collapse

DEATH_HANDLER =
(lambda do |job, _ex|
  return unless (digest = job["lock_digest"])

  SidekiqUniqueJobs::Digests.new.delete_by_digest(digest)
end).freeze

Class Method Summary collapse

Class Method Details

.configure(config) ⇒ Sidekiq

Configure the server middleware

Returns:

  • (Sidekiq)

    the sidekiq configuration



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

def self.configure(config)
  config.on(:startup)  { start }
  config.on(:shutdown) { stop }

  return unless config.respond_to?(:death_handlers)

  config.death_handlers << death_handler
end

.death_handlerlambda

A death handler for dead jobs

Returns:

  • (lambda)


56
57
58
# File 'lib/sidekiq_unique_jobs/server.rb', line 56

def self.death_handler
  DEATH_HANDLER
end

.startvoid

This method returns an undefined value.

Start the sidekiq unique jobs server process



34
35
36
37
38
# File 'lib/sidekiq_unique_jobs/server.rb', line 34

def self.start
  SidekiqUniqueJobs::UpdateVersion.call
  SidekiqUniqueJobs::Orphans::Manager.start
  SidekiqUniqueJobs::Orphans::ReaperResurrector.start
end

.stopvoid

This method returns an undefined value.

Stop the sidekiq unique jobs server process



46
47
48
# File 'lib/sidekiq_unique_jobs/server.rb', line 46

def self.stop
  SidekiqUniqueJobs::Orphans::Manager.stop
end