mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 02:26:00 +08:00
proto modify
This commit is contained in:
@@ -3,7 +3,9 @@ package kafka
|
||||
import (
|
||||
"OpenIM/pkg/common/config"
|
||||
log "OpenIM/pkg/common/log"
|
||||
"OpenIM/pkg/common/tracelog"
|
||||
"OpenIM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
@@ -43,7 +45,8 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p *Producer) SendMessage(m proto.Message, key string, operationID string) (int32, int64, error) {
|
||||
func (p *Producer) SendMessage(ctx context.Context, m proto.Message, key string) (int32, int64, error) {
|
||||
operationID := tracelog.GetOperationID(ctx)
|
||||
log.Info(operationID, "SendMessage", "key ", key, m.String(), p.producer)
|
||||
kMsg := &sarama.ProducerMessage{}
|
||||
kMsg.Topic = p.topic
|
||||
@@ -63,6 +66,7 @@ func (p *Producer) SendMessage(m proto.Message, key string, operationID string)
|
||||
log.Error(operationID, "kMsg.Key.Length() == 0 || kMsg.Value.Length() == 0 ", kMsg)
|
||||
return -1, -1, errors.New("key or value == 0")
|
||||
}
|
||||
kMsg.Metadata = ctx
|
||||
partition, offset, err := p.producer.SendMessage(kMsg)
|
||||
log.Info(operationID, "ByteEncoder SendMessage end", "key ", kMsg.Key.Length(), kMsg.Value.Length(), p.producer)
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user