Class: Karafka::BaseConsumer

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::DescendantsTracker, Forwardable
Defined in:
lib/karafka/base_consumer.rb

Overview

Base consumer from which all Karafka consumers should inherit

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.topicObject

Returns the value of attribute topic.



18
19
20
# File 'lib/karafka/base_consumer.rb', line 18

def topic
  @topic
end

Instance Attribute Details

#params_batch=(messages) ⇒ Karafka::Params::ParamsBatch

Note:

Until first params usage, it won’t parse data at all

Creates lazy loaded params batch object

Parameters:

  • messages (Array<Kafka::FetchedMessage>, Array<Hash>)

    messages with raw content (from Kafka) or messages inside a hash (from backend, etc)

Returns:



40
41
42
# File 'lib/karafka/base_consumer.rb', line 40

def params_batch=(messages)
  @params_batch = Karafka::Params::ParamsBatch.new(messages, topic.parser)
end

Instance Method Details

#callObject

Executes the default consumer flow.



45
46
47
# File 'lib/karafka/base_consumer.rb', line 45

def call
  process
end

#topicKarafka::Routing::Topic

Returns topic to which a given consumer is subscribed.

Returns:



31
32
33
# File 'lib/karafka/base_consumer.rb', line 31

def topic
  self.class.topic
end