Compare commits

..

5 Commits

Author SHA1 Message Date
f4f8793686 fixup connected status
All checks were successful
test / test (push) Successful in 2m25s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-03-07 11:45:36 +03:00
ec4922ad8b fixup connected status
Some checks failed
test / test (push) Has been cancelled
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-03-07 11:44:56 +03:00
eaea14e5a8 fixup connected status
All checks were successful
test / test (push) Successful in 3m3s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-03-07 11:26:34 +03:00
f6f7139d2f fixup panic
All checks were successful
test / test (push) Successful in 2m4s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-03-03 10:43:41 +03:00
51e4118dfc cleanup
All checks were successful
test / test (push) Successful in 2m19s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-02-27 12:41:42 +03:00
2 changed files with 7 additions and 6 deletions

10
kgo.go
View File

@@ -142,9 +142,10 @@ func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, *ho
}
return nil, nil, err
}
}
k.connected.Store(1)
return c, htracer, nil
}
}
func (k *Broker) Connect(ctx context.Context) error {
if k.connected.Load() == 1 {
@@ -267,7 +268,7 @@ func (k *Broker) publish(ctx context.Context, msgs []*broker.Message, opts ...br
k.connected.Store(1)
}
k.Unlock()
fmt.Printf("EEE\n")
options := broker.NewPublishOptions(opts...)
records := make([]*kgo.Record, 0, len(msgs))
var errs []string
@@ -322,9 +323,9 @@ func (k *Broker) publish(ctx context.Context, msgs []*broker.Message, opts ...br
return nil
}
ts := time.Now()
fmt.Printf("SSSSSSEEE\n")
results := k.c.ProduceSync(ctx, records...)
fmt.Printf("SSSSSS\n")
te := time.Since(ts)
for _, result := range results {
k.opts.Meter.Summary(semconv.PublishMessageLatencyMicroseconds, "endpoint", result.Record.Topic, "topic", result.Record.Topic).Update(te.Seconds())
@@ -404,6 +405,7 @@ func (k *Broker) Subscribe(ctx context.Context, topic string, handler broker.Han
consumers: make(map[tp]*consumer),
done: make(chan struct{}),
fatalOnError: fatalOnError,
connected: k.connected,
}
kopts := append(k.kopts,

View File

@@ -2,7 +2,6 @@ package kgo_test
import (
"context"
"fmt"
"os"
"strings"
"sync/atomic"
@@ -214,7 +213,7 @@ func TestPubSub(t *testing.T) {
if prc := atomic.LoadInt64(&idx); prc == msgcnt {
close(done)
} else {
fmt.Printf("processed %v\n", prc)
t.Logf("processed %v\n", prc)
}
case <-ticker.C:
close(done)