fix double init
Some checks failed
build / test (push) Failing after 1m31s
build / lint (push) Successful in 9m19s
codeql / analyze (go) (push) Failing after 13m43s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-03-07 09:05:47 +03:00
parent 947132c25b
commit cbab0b5cb6

6
kgo.go
View File

@ -53,6 +53,7 @@ var DefaultRetryBackoffFn = func() func(int) time.Duration {
}()
type Broker struct {
init bool
c *kgo.Client
kopts []kgo.Opt
connected bool
@ -155,6 +156,10 @@ func (k *Broker) Init(opts ...broker.Option) error {
k.Lock()
defer k.Unlock()
if len(opts) == 0 && k.init {
return nil
}
for _, o := range opts {
o(&k.opts)
}
@ -178,6 +183,7 @@ func (k *Broker) Init(opts ...broker.Option) error {
}
}
k.init = true
return nil
}