Class: Karafka::Web::Pro::Commanding::Matchers::Base
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Commanding::Matchers::Base
- Defined in:
- lib/karafka/web/pro/commanding/matchers/base.rb
Overview
Base class for all sub-matchers.
Sub-matchers receive the full message and extract the relevant data they need. This provides a consistent API across all matchers.
Matchers have two methods:
-
‘apply?` - returns true if this matcher’s criterion is present and should be checked
-
‘matches?` - returns true if the criterion matches (only called if apply? is true)
Required matchers (MessageType, SchemaVersion) always apply. Optional matchers (ProcessId, ConsumerGroupId, Topic) decide if they should be applied
based on the details
Direct Known Subclasses
ConsumerGroupId, MessageType, PartitionId, ProcessId, SchemaVersion, Topic
Class Attribute Summary collapse
-
.priority ⇒ Integer
Priority determines the order in which matchers are checked.
Instance Method Summary collapse
-
#apply? ⇒ Boolean
Checks if this matcher should be applied to the message.
-
#initialize(message) ⇒ Base
constructor
A new instance of Base.
-
#matches? ⇒ Boolean
Checks if the criterion is satisfied.
Constructor Details
#initialize(message) ⇒ Base
Returns a new instance of Base.
67 68 69 |
# File 'lib/karafka/web/pro/commanding/matchers/base.rb', line 67 def initialize() @message = end |
Class Attribute Details
.priority ⇒ Integer
Priority determines the order in which matchers are checked. Lower values are checked first. Required matchers should have lower priority.
61 62 63 |
# File 'lib/karafka/web/pro/commanding/matchers/base.rb', line 61 def priority @priority || 100 end |
Instance Method Details
#apply? ⇒ Boolean
Checks if this matcher should be applied to the message. Override in subclasses for optional matchers.
75 76 77 |
# File 'lib/karafka/web/pro/commanding/matchers/base.rb', line 75 def apply? true end |
#matches? ⇒ Boolean
Checks if the criterion is satisfied. Only called when apply? returns true.
83 84 85 |
# File 'lib/karafka/web/pro/commanding/matchers/base.rb', line 83 def matches? raise NotImplementedError, "Implement in a subclass" end |