Files
cybertron-log-enricher/configs/kafka.go
Varnit Goyal f20af81520 Tp 55555/integrate document service client (#5)
* TP-55555 | document client and kafka integration

* TP-55555 | introduce service concept refactor code
2024-07-27 17:00:47 +05:30

41 lines
1.4 KiB
Go

package configs
import (
"github.com/spf13/viper"
"strings"
)
type KafkaConfig struct {
Brokers []string
Username string
Password string
Group map[string]string
Topics map[string]string
TlsInsureSkipVerification bool
TlsEnabled bool
SaslEnabled bool
ConsumerBatchSize int
GoroutinesMaxPoolSize int
ConsumerMaxTimeoutMs string
}
func NewKafkaConfig() *KafkaConfig {
return &KafkaConfig{
Brokers: strings.Split(viper.GetString("kafka.brokers"), ","),
Username: viper.GetString("kafka.username"),
Password: viper.GetString("kafka.password"),
Group: viper.GetStringMapString("kafka.group.names"),
Topics: viper.GetStringMapString("kafka.topics"),
TlsInsureSkipVerification: viper.GetBool("kafka.tls.insecureSkipVerify"),
SaslEnabled: viper.GetBool("kafka.sasl.enabled"),
TlsEnabled: viper.GetBool("kafka.tls.enabled"),
ConsumerBatchSize: viper.GetInt("kafka.consumer.batch.size"),
GoroutinesMaxPoolSize: viper.GetInt("kafka.consumer.goroutines.max.pool.size"),
ConsumerMaxTimeoutMs: viper.GetString("kafka.consumer.max.timeout.ms"),
}
}
func (kc *KafkaConfig) GetTopic(topic string) string {
return kc.Topics[topic]
}