Module: Karafka::Routing::Router
- Defined in:
- lib/karafka/routing/router.rb
Overview
Note:
Since Kafka does not provide namespaces or modules for topics, they all have “flat” structure so all the routes are being stored in a single level array
Karafka framework Router for routing incoming messages to proper consumers
Class Method Summary collapse
-
.find(topic_id) ⇒ Karafka::Routing::Topic
Find a proper topic based on full topic id.
-
.find_by(lookup) ⇒ Karafka::Routing::Topic?
Finds first reference of a given topic based on provided lookup attribute.
Class Method Details
.find(topic_id) ⇒ Karafka::Routing::Topic
Find a proper topic based on full topic id
16 17 18 |
# File 'lib/karafka/routing/router.rb', line 16 def find(topic_id) find_by(id: topic_id) || raise(Errors::NonMatchingRouteError, topic_id) end |
.find_by(lookup) ⇒ Karafka::Routing::Topic?
Finds first reference of a given topic based on provided lookup attribute
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/karafka/routing/router.rb', line 23 def find_by(lookup) App.consumer_groups.each do |consumer_group| consumer_group.topics.each do |topic| return topic if lookup.all? do |attribute, value| topic.public_send(attribute) == value end end end nil end |