Class: Karafka::Processing::ConsumerGroups::StrategySelector
- Inherits:
-
Object
- Object
- Karafka::Processing::ConsumerGroups::StrategySelector
- Defined in:
- lib/karafka/processing/consumer_groups/strategy_selector.rb
Overview
Selector of appropriate processing strategy matching topic combinations
Constant Summary collapse
- SUPPORTED_FEATURES =
Features we support in the OSS offering.
%i[ active_job manual_offset_management dead_letter_queue ].freeze
Instance Attribute Summary collapse
-
#strategies ⇒ Object
readonly
Returns the value of attribute strategies.
Instance Method Summary collapse
-
#find(topic) ⇒ Module
Module with proper strategy.
-
#initialize ⇒ StrategySelector
constructor
Initializes the strategy selector and preloads all strategies.
Constructor Details
#initialize ⇒ StrategySelector
Initializes the strategy selector and preloads all strategies
18 19 20 21 |
# File 'lib/karafka/processing/consumer_groups/strategy_selector.rb', line 18 def initialize # We load them once for performance reasons not to do too many lookups @strategies = find_all end |
Instance Attribute Details
#strategies ⇒ Object (readonly)
Returns the value of attribute strategies.
8 9 10 |
# File 'lib/karafka/processing/consumer_groups/strategy_selector.rb', line 8 def strategies @strategies end |
Instance Method Details
#find(topic) ⇒ Module
Returns module with proper strategy.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/karafka/processing/consumer_groups/strategy_selector.rb', line 26 def find(topic) feature_set = SUPPORTED_FEATURES.map do |feature_name| topic.public_send("#{feature_name}?") ? feature_name : nil end feature_set.compact! @strategies.find do |strategy| strategy::FEATURES.sort == feature_set.sort end || raise(Errors::StrategyNotFoundError, topic.name) end |