Module: Karafka::Admin::Configs

Defined in:
lib/karafka/admin/configs.rb,
lib/karafka/admin/configs/config.rb,
lib/karafka/admin/configs/resource.rb

Overview

Namespace for admin operations related to configuration management

At the moment Karafka supports configuration management for brokers and topics

You can describe configuration as well as alter it.

Altering is done in the incremental way.

Defined Under Namespace

Classes: Config, Resource

Class Method Summary collapse

Class Method Details

.alter(*resources) ⇒ Object

Note:

This operation is not transactional and can work only partially if some config options are not valid. Always make sure, your alterations are correct.

Note:

We call it ‘#alter` despite using the Kafka incremental alter API because the regular alter is deprecated.

Alters given resources based on the alteration operations accumulated in the provided resources

Examples:

Alter the ‘delete.retention.ms` and set it to 8640001

resource = Karafka::Admin::Configs::Resource.new(type: :topic, name: 'example')
resource.set('delete.retention.ms', '8640001')
Karafka::Admin::Configs.alter(resource)

Parameters:

  • resources (Resource, Array<Resource>)

    single resource we want to alter or list of resources.



54
55
56
57
58
59
# File 'lib/karafka/admin/configs.rb', line 54

def alter(*resources)
  operate_on_resources(
    :incremental_alter_configs,
    resources
  )
end

.describe(*resources) ⇒ Array<Resource>

Note:

Even if you request one resource, result will always be an array with resources

Fetches given resources configurations from Kafka

Examples:

Describe topic named “example” and print its config

resource = Karafka::Admin::Configs::Resource.new(type: :topic, name: 'example')
results = Karafka::Admin::Configs.describe(resource)
results.first.configs.each do |config|
  puts "#{config.name} - #{config.value}"
end

Parameters:

  • resources (Resource, Array<Resource>)

    single resource we want to describe or list of resources we are interested in. It is useful to provide multiple resources when you need data from multiple topics, etc. Karafka will make one query for all the data instead of doing one per topic.

Returns:

  • (Array<Resource>)

    array with resources containing their configuration details



31
32
33
34
35
36
# File 'lib/karafka/admin/configs.rb', line 31

def describe(*resources)
  operate_on_resources(
    :describe_configs,
    resources
  )
end