overflow_gateway_probe/external/kafka/kafka.go

25 lines
438 B
Go
Raw Normal View History

2018-04-01 09:39:05 +00:00
package kafka
import (
"git.loafle.net/commons_go/logging"
"github.com/segmentio/kafka-go"
)
var (
kafkaWriter *kafka.Writer
)
func ExternalInit() {
kafkaWriter = kafka.NewWriter(kafka.WriterConfig{
Brokers: []string{"192.168.1.50:9092"},
2018-04-01 10:08:46 +00:00
Topic: "overflow-metric-topic",
2018-04-01 09:39:05 +00:00
Balancer: &kafka.LeastBytes{},
})
}
func ExternalDestroy() {
if err := kafkaWriter.Close(); nil != err {
logging.Logger().Errorf("%v", err)
}
}