Class: Karafka::BaseController

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

Overview

Base controller from which all Karafka controllers should inherit

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.topicObject

Returns the value of attribute topic.



10
11
12
# File 'lib/karafka/base_controller.rb', line 10

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:



32
33
34
# File 'lib/karafka/base_controller.rb', line 32

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

Instance Method Details

#callObject

Executes the default controller flow.



37
38
39
# File 'lib/karafka/base_controller.rb', line 37

def call
  process
end

#topicKarafka::Routing::Topic

Returns topic to which a given controller is subscribed.

Returns:



23
24
25
# File 'lib/karafka/base_controller.rb', line 23

def topic
  self.class.topic
end