Class: Sidekiq::Antidote::Inhibitor
- Inherits:
-
Object
- Object
- Sidekiq::Antidote::Inhibitor
- Defined in:
- lib/sidekiq/antidote/inhibitor.rb
Overview
Single poison inhibition rule: class qualifier + treatment action.
Constant Summary collapse
- TREATMENTS =
%w[skip kill].freeze
Instance Attribute Summary collapse
- #class_qualifier ⇒ ClassQualifier readonly
- #id ⇒ String readonly
- #treatment ⇒ "skip", "kill" readonly
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(id:, treatment:, class_qualifier:) ⇒ Inhibitor
constructor
A new instance of Inhibitor.
- #match?(job_record) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(id:, treatment:, class_qualifier:) ⇒ Inhibitor
Returns a new instance of Inhibitor.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 25 def initialize(id:, treatment:, class_qualifier:) @id = -id.to_s @treatment = -treatment.to_s @class_qualifier = ClassQualifier.new(class_qualifier.to_s) raise ArgumentError, "invalid id: #{id.inspect}" if @id.empty? raise ArgumentError, "invalid treatment: #{treatment.inspect}" unless TREATMENTS.include?(@treatment) freeze end |
Instance Attribute Details
#class_qualifier ⇒ ClassQualifier (readonly)
20 21 22 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 20 def class_qualifier @class_qualifier end |
#id ⇒ String (readonly)
14 15 16 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 14 def id @id end |
#treatment ⇒ "skip", "kill" (readonly)
17 18 19 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 17 def treatment @treatment end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
44 45 46 47 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 44 def eql?(other) self.class == other.class \ && id == other.id && treatment == other.treatment && class_qualifier == other.class_qualifier end |
#match?(job_record) ⇒ Boolean
36 37 38 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 36 def match?(job_record) class_qualifier.match?(job_record.display_class) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/sidekiq/antidote/inhibitor.rb', line 40 def to_s "#{treatment} #{class_qualifier}" end |