fixup panic
Some checks failed
build / test (push) Failing after 1m32s
codeql / analyze (go) (push) Failing after 2m37s
build / lint (push) Successful in 9m31s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-05-02 10:32:29 +03:00
parent 6a68533824
commit c240631cdb

4
kgo.go
View File

@ -98,8 +98,10 @@ func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, err
select {
case <-ctx.Done():
if ctx.Err() != nil {
if sp != nil {
sp.SetStatus(tracer.SpanStatusError, ctx.Err().Error())
}
}
return nil, ctx.Err()
default:
c, err = kgo.NewClient(opts...)
@ -107,7 +109,9 @@ func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, err
err = c.Ping(ctx) // check connectivity to cluster
}
if err != nil {
if sp != nil {
sp.SetStatus(tracer.SpanStatusError, err.Error())
}
return nil, err
}
}