Class: NeetoCommonsBackend::BaseWorkers::Base

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/neeto_commons_backend/base_workers/base.rb

Direct Known Subclasses

Auth, Default, Low, Urgent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.delete_matched(worker_name, arguments) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/workers/neeto_commons_backend/base_workers/base.rb', line 31

def self.delete_matched(worker_name, arguments)
  set = Sidekiq::ScheduledSet.new

  set = if arguments.is_a?(Array) && arguments.first.is_a?(String)
    set.scan arguments.first
        elsif arguments.is_a?(String)
          set.scan arguments
        else
          set.scan worker_name
  end

  set.each do |job|
    job.delete if job.display_class == worker_name && job.args == [arguments]
  end
end

.perform_unique_async(*arguments) ⇒ Object



13
14
15
16
17
# File 'app/workers/neeto_commons_backend/base_workers/base.rb', line 13

def self.perform_unique_async(*arguments)
  self.delete_matched(name, arguments)

  self.perform_async(arguments)
end

.perform_unique_at(t, *arguments) ⇒ Object



25
26
27
28
29
# File 'app/workers/neeto_commons_backend/base_workers/base.rb', line 25

def self.perform_unique_at(t, *arguments)
  self.delete_matched(name, arguments)

  self.perform_at(t, arguments)
end

.perform_unique_in(t, *arguments) ⇒ Object



19
20
21
22
23
# File 'app/workers/neeto_commons_backend/base_workers/base.rb', line 19

def self.perform_unique_in(t, *arguments)
  self.delete_matched(name, arguments)

  self.perform_in(t, arguments)
end

Instance Method Details

#perform(*arguments) ⇒ Object



47
48
49
# File 'app/workers/neeto_commons_backend/base_workers/base.rb', line 47

def perform(*arguments)
  Honeybadger.context(job_name: self.class.name, app_name: Rails.application.engine_name)
end