Class: Karafka::Routing::Builder
- Inherits:
-
Array
- Object
- Array
- Karafka::Routing::Builder
- Includes:
- Singleton
- Defined in:
- lib/karafka/routing/builder.rb
Overview
Builder used as a DSL layer for building consumers and telling them which topics to consume
Instance Method Summary collapse
-
#active ⇒ Array<Karafka::Routing::ConsumerGroup>
Only active consumer groups that we want to use.
-
#draw { ... } ⇒ Object
Used to draw routes for Karafka.
Instance Method Details
#active ⇒ Array<Karafka::Routing::ConsumerGroup>
Returns only active consumer groups that we want to use. Since Karafka supports multi-process setup, we need to be able to pick only those consumer groups that should be active in our given process context.
38 39 40 |
# File 'lib/karafka/routing/builder.rb', line 38 def active select(&:active?) end |
#draw { ... } ⇒ Object
Note:
After it is done drawing it will store and validate all the routes to make sure that they are correct and that there are no topic/group duplications (this is forbidden)
Used to draw routes for Karafka
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/karafka/routing/builder.rb', line 24 def draw(&block) instance_eval(&block) each do |consumer_group| hashed_group = consumer_group.to_h validation_result = Karafka::Schemas::ConsumerGroup.call(hashed_group) return if validation_result.success? raise Errors::InvalidConfiguration, validation_result.errors end end |