25 lines
438 B
Go
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)
|
|
}
|
|
}
|