Class: Karafka::Messages::BatchMetadata

Inherits:
Struct
  • Object
show all
Defined in:
lib/karafka/messages/batch_metadata.rb

Overview

Note:

This metadata object refers to per batch metadata, not ‘#message.metadata`

Simple batch metadata object that stores all non-message information received from Kafka cluster while fetching the data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def created_at
  @created_at
end

#deserializerObject

Returns the value of attribute deserializer

Returns:

  • (Object)

    the current value of deserializer



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def deserializer
  @deserializer
end

#first_offsetObject

Returns the value of attribute first_offset

Returns:

  • (Object)

    the current value of first_offset



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def first_offset
  @first_offset
end

#last_offsetObject

Returns the value of attribute last_offset

Returns:

  • (Object)

    the current value of last_offset



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def last_offset
  @last_offset
end

#partitionObject

Returns the value of attribute partition

Returns:

  • (Object)

    the current value of partition



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def partition
  @partition
end

#processed_atObject

Returns the value of attribute processed_at

Returns:

  • (Object)

    the current value of processed_at



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def processed_at
  @processed_at
end

#scheduled_atObject

Returns the value of attribute scheduled_at

Returns:

  • (Object)

    the current value of scheduled_at



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def scheduled_at
  @scheduled_at
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def size
  @size
end

#topicObject

Returns the value of attribute topic

Returns:

  • (Object)

    the current value of topic



9
10
11
# File 'lib/karafka/messages/batch_metadata.rb', line 9

def topic
  @topic
end

Instance Method Details

#consumption_lagInteger

Note:

In case of usage in workless flows, this value will be set to -1

This lag describes how long did it take for a message to be consumed from the moment it was created

Returns:

  • (Integer)

    number of milliseconds



27
28
29
# File 'lib/karafka/messages/batch_metadata.rb', line 27

def consumption_lag
  processed_at ? time_distance_in_ms(processed_at, created_at) : -1
end

#processing_lagInteger

Note:

In case of usage in workless flows, this value will be set to -1

This lag describes how long did a batch have to wait before it was picked up by one of the workers

Returns:

  • (Integer)

    number of milliseconds



36
37
38
# File 'lib/karafka/messages/batch_metadata.rb', line 36

def processing_lag
  processed_at ? time_distance_in_ms(processed_at, scheduled_at) : -1
end