Module: Karafka::Pro::Routing::Features::ConsumerGroups::OffsetMetadata::Topic

Defined in:
lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb

Overview

Commit Metadata API extensions

Instance Method Summary collapse

Instance Method Details

#initializeObject

This method sets up the extra instance variable to nil before calling the parent class initializer. The explicit initialization to nil is included as an optimization for Ruby's object shapes system, which improves memory layout and access performance.



52
53
54
55
# File 'lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb', line 52

def initialize(...)
  @offset_metadata = nil
  super
end

#offset_metadata(cache: true, deserializer: STRING_DESERIALIZER) ⇒ Config

Returns this feature config.

Parameters:

  • cache (Boolean) (defaults to: true)

    should we cache the response until rebalance

  • deserializer (#call) (defaults to: STRING_DESERIALIZER)

    deserializer that will get raw data and should return deserialized metadata

Returns:

  • (Config)

    this feature config



61
62
63
64
65
66
67
# File 'lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb', line 61

def (cache: true, deserializer: STRING_DESERIALIZER)
  @offset_metadata ||= Config.new(
    active: true,
    cache: cache,
    deserializer: deserializer
  )
end

#offset_metadata?true

Returns is offset metadata active (it always is).

Returns:

  • (true)

    is offset metadata active (it always is)



70
71
72
# File 'lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb', line 70

def offset_metadata?
  .active?
end

#to_hHash

Returns topic with all its native configuration options plus offset metadata settings.

Returns:

  • (Hash)

    topic with all its native configuration options plus offset metadata settings



76
77
78
79
80
# File 'lib/karafka/pro/routing/features/consumer_groups/offset_metadata/topic.rb', line 76

def to_h
  super.merge(
    offset_metadata: .to_h
  ).freeze
end