Class: Sidekiq::Undertaker::JobFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/undertaker/job_filter.rb

Class Method Summary collapse

Class Method Details

.all_error_msgs?(filter, value) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/sidekiq/undertaker/job_filter.rb', line 45

def all_error_msgs?(filter, value)
  filter == "error_msg" && value == "all"
end

.all_errors?(filter, value) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/sidekiq/undertaker/job_filter.rb', line 41

def all_errors?(filter, value)
  filter == "error_class" && value == "all"
end

.all_jobs?(filter, value) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/sidekiq/undertaker/job_filter.rb', line 37

def all_jobs?(filter, value)
  filter == "job_class" && value == "all"
end

.filter_dead_jobs(filters = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sidekiq/undertaker/job_filter.rb', line 9

def filter_dead_jobs(filters = {})
  # filters can have keys in (job_class, error_class, error_msg, bucket_name)
  dead_jobs = []
  Sidekiq::Undertaker::DeadJob.for_each do |dead_job|
    filter_passed = true
    filters.each do |filter, value|
      next if skip?(filter, value)

      filter_passed = false if dead_job.respond_to?(filter) && dead_job.public_send(filter) != value
    end
    dead_jobs << dead_job if filter_passed
  end

  dead_jobs
end

.skip?(filter, value) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/sidekiq/undertaker/job_filter.rb', line 25

def skip?(filter, value)
  value.nil? ||
    total_dead_bucket?(filter, value) ||
    all_jobs?(filter, value) ||
    all_errors?(filter, value) ||
    all_error_msgs?(filter, value)
end

.total_dead_bucket?(filter, value) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/sidekiq/undertaker/job_filter.rb', line 33

def total_dead_bucket?(filter, value)
  filter == "bucket_name" && value == "total_dead"
end