kafka.go
612 字节
package constant
import (
"os"
"strings"
)
type KafkaConfig struct {
Servers []string `json:"servers"`
ConsumerId string `json:"consumerGroup"`
}
var KafkaCfg KafkaConfig
func init() {
KafkaCfg = KafkaConfig{
Servers: []string{"106.52.15.41:9092"},
ConsumerId: "partnermg_dev",
}
if os.Getenv("KAFKA_HOST") != "" {
kafkaHost := os.Getenv("KAFKA_HOST")
KafkaCfg.Servers = strings.Split(kafkaHost, ";")
}
if os.Getenv("KAFKA_CONSUMER_ID") != "" {
consumerId := os.Getenv("KAFKA_CONSUMER_ID")
KafkaCfg.ConsumerId = consumerId
}
}
// "192.168.190.136:9092",
// "106.52.15.41:9092"