Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
d6e73a3419 |
11
kgo.go
11
kgo.go
@@ -344,23 +344,12 @@ func (b *Broker) fnPublish(ctx context.Context, topic string, messages ...broker
|
||||
}
|
||||
|
||||
func (b *Broker) publish(ctx context.Context, topic string, messages ...broker.Message) error {
|
||||
if b.connected.Load() == 0 {
|
||||
c, _, err := b.connect(ctx, b.kopts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.Lock()
|
||||
b.c = c
|
||||
b.Unlock()
|
||||
}
|
||||
|
||||
records := make([]*kgo.Record, 0, len(messages))
|
||||
var errs []string
|
||||
var key []byte
|
||||
var promise func(*kgo.Record, error)
|
||||
|
||||
for _, msg := range messages {
|
||||
|
||||
if mctx := msg.Context(); mctx != nil {
|
||||
if k, ok := mctx.Value(publishKey{}).([]byte); ok && k != nil {
|
||||
key = k
|
||||
|
@@ -222,7 +222,7 @@ func TestPubSub(t *testing.T) {
|
||||
if prc := atomic.LoadInt64(&idx); prc == msgcnt {
|
||||
close(done)
|
||||
} else {
|
||||
t.Logf("processed %v\n", prc)
|
||||
t.Logf("processed %v of %v\n", prc, msgcnt)
|
||||
}
|
||||
case <-ticker.C:
|
||||
close(done)
|
||||
|
Reference in New Issue
Block a user