Class: Karafka::Admin::Configs

Inherits:
Karafka::Admin show all
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

Constant Summary

Constants inherited from Karafka::Admin

Recovery

Instance Attribute Summary

Attributes inherited from Karafka::Admin

#custom_kafka

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Karafka::Admin

cluster_info, #cluster_info, copy_consumer_group, #copy_consumer_group, create_partitions, #create_partitions, create_topic, #create_topic, delete_consumer_group, #delete_consumer_group, delete_topic, #delete_topic, #initialize, plan_topic_replication, #plan_topic_replication, read_lags_with_offsets, #read_lags_with_offsets, read_topic, #read_topic, read_watermark_offsets, #read_watermark_offsets, rename_consumer_group, #rename_consumer_group, seek_consumer_group, #seek_consumer_group, topic_info, #topic_info, trigger_rebalance, #trigger_rebalance, with_admin, #with_admin, with_consumer, #with_consumer

Constructor Details

This class inherits a constructor from Karafka::Admin

Class Method Details

.alter(*resources) ⇒ Object

Parameters:

  • resources (Resource, Array<Resource>)

    single resource or list of resources with accumulated alteration operations to apply

See Also:



24
25
26
# File 'lib/karafka/admin/configs.rb', line 24

def alter(*resources)
  new.alter(*resources)
end

.describe(*resources) ⇒ Object

Parameters:

  • resources (Resource, Array<Resource>)

    single resource or list of resources to fetch configuration from Kafka

See Also:



17
18
19
# File 'lib/karafka/admin/configs.rb', line 17

def describe(*resources)
  new.describe(*resources)
end

Instance 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.



69
70
71
72
73
74
# File 'lib/karafka/admin/configs.rb', line 69

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



46
47
48
49
50
51
# File 'lib/karafka/admin/configs.rb', line 46

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