审查视图

pkg/constant/kafka.go 611 字节
唐旭辉 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package constant

import (
	"os"
	"strings"
)

type KafkaConfig struct {
	Servers    []string `json:"servers"`
	ConsumerId string   `json:"consumerGroup"`
}

var KafkaCfg KafkaConfig

func init() {
	KafkaCfg = KafkaConfig{
17
		Servers:    []string{"127.0.0.1:9092"},
唐旭辉 authored
18
		ConsumerId: "partnermg_local",
唐旭辉 authored
19 20 21 22 23
	}
	if os.Getenv("KAFKA_HOST") != "" {
		kafkaHost := os.Getenv("KAFKA_HOST")
		KafkaCfg.Servers = strings.Split(kafkaHost, ";")
	}
唐旭辉 authored
24 25 26 27
	if os.Getenv("KAFKA_CONSUMER_ID") != "" {
		consumerId := os.Getenv("KAFKA_CONSUMER_ID")
		KafkaCfg.ConsumerId = consumerId
	}
唐旭辉 authored
28
}
唐旭辉 authored
29 30 31

// "192.168.190.136:9092",
// "106.52.15.41:9092"