File: Util.pm

package info (click to toggle)
libnet-kafka-perl 1.06-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 356 kB
  • sloc: ansic: 3,575; perl: 1,002; sh: 4; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 613 bytes parent folder | download
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;