1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
package Net::Kafka::Util;
use strict;
use warnings;
use Net::Kafka qw/RD_KAFKA_TOPIC_CONFIG_KEYS/;
my $topic_config_key_lookup = { map { $_ => 1 } @{ +RD_KAFKA_TOPIC_CONFIG_KEYS } };
sub is_topic_config_key {
my $key = shift;
return exists $topic_config_key_lookup->{$key} ? 1 : 0;
}
sub build_config {
my $args = shift;
my $config = {};
foreach my $key (keys %$args) {
if (is_topic_config_key($key)) {
$config->{default_topic_config}{$key} = $args->{$key};
} else {
$config->{$key} = $args->{$key};
}
}
return $config;
}
1;
|