overflow_gateway_probe/external/kafka/kafka.go
crusader b7424d7b2f ing
2018-04-01 19:08:46 +09:00

25 lines
438 B
Go

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"},
Topic: "overflow-metric-topic",
Balancer: &kafka.LeastBytes{},
})
}
func ExternalDestroy() {
if err := kafkaWriter.Close(); nil != err {
logging.Logger().Errorf("%v", err)
}
}