pull/455/head
Gordon 2 years ago committed by Xinwei Xiong(cubxxw-openim)
parent a97eb7b7c9
commit 4c5b4a38fc

@ -33,12 +33,10 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
return &p
}
func (p *Producer) SendMessage(m proto.Message, key ...string) (int32, int64, error) {
func (p *Producer) SendMessage(m proto.Message, key string) (int32, int64, error) {
kMsg := &sarama.ProducerMessage{}
kMsg.Topic = p.topic
if len(key) == 1 {
kMsg.Key = sarama.StringEncoder(key[0])
}
kMsg.Key = sarama.StringEncoder(key)
bMsg, err := proto.Marshal(m)
if err != nil {
log2.Error("", "", "proto marshal err = %s", err.Error())

Loading…
Cancel
Save