Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeKafkaReader ¶
func InitializeKafkaReader(kafkacfg *KafkaConfig, separator string, suffix ...string) (*kafka.Reader, error)
InitializeKafkaReader initializes a Kafka reader with the provided configuration.
func InitializeKafkaWriter ¶
func InitializeKafkaWriter(kafkacfg *KafkaConfig, separator string, suffix ...string) (*kafka.Writer, error)
InitializeKafkaWriter initializes a Kafka writer with the provided configuration and optional topic suffix. If KAFKA_TOPIC is set, the suffix is ignored and the topic is used directly. If KAFKA_TOPIC_PREFIX is set and KAFKA_TOPIC is not set, the topic will be KAFKA_TOPIC_PREFIX + "." + suffix. The suffix parameter is optional - pass an empty string or omit it for backward compatibility.
Types ¶
type KafkaConfig ¶
type KafkaConfig struct {
Address string `mapstructure:"address"`
Topic string `mapstructure:"topic"`
TopicPrefix string `mapstructure:"topic_prefix"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
GroupID string `mapstructure:"groupid"`
Partition string `mapstructure:"partition"`
InsecureSkipVerify string `mapstructure:"insecure_skip_verify"`
// StartOffset determines where a new consumer group starts reading.
// Valid values: "first" (default, oldest messages) or "last" (newest messages only).
// Only applies when GroupID is set and the consumer group has no committed offsets.
StartOffset string `mapstructure:"start_offset"`
}
KafkaConfig represents the configuration for Kafka.
func LoadConfig ¶
func LoadConfig() (*KafkaConfig, error)
LoadConfig loads the configuration from environment variables using Viper. An isolated viper instance is used to prevent cross-package state pollution.