24 lines
329 B
Go
24 lines
329 B
Go
package kafka
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/segmentio/kafka-go"
|
|
)
|
|
|
|
func Send(key []byte, value []byte) error {
|
|
if nil == kafkaWriter {
|
|
return fmt.Errorf("Kafka client is not valid")
|
|
}
|
|
|
|
err := kafkaWriter.WriteMessages(context.Background(),
|
|
kafka.Message{
|
|
Key: key,
|
|
Value: value,
|
|
},
|
|
)
|
|
|
|
return err
|
|
}
|