Class: Karafka::Connection::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/connection/listener.rb

Overview

Note:

It does not loop on itself - it needs to be executed in a loop

Note:

Listener itself does nothing with the message - it will return to the block a raw Kafka::FetchedMessage

A single listener that listens to incoming messages from a single route

Instance Method Summary collapse

Constructor Details

#initialize(consumer_group) ⇒ Karafka::Connection::Listener

Returns listener instance.

Parameters:



13
14
15
# File 'lib/karafka/connection/listener.rb', line 13

def initialize(consumer_group)
  @consumer_group = consumer_group
end

Instance Method Details

#callObject

Runs prefetch callbacks and executes the main listener fetch loop



18
19
20
21
22
23
24
25
# File 'lib/karafka/connection/listener.rb', line 18

def call
  Karafka.monitor.instrument(
    'connection.listener.before_fetch_loop',
    consumer_group: @consumer_group,
    client: client
  )
  fetch_loop
end