From cbab0b5cb6d45d1381b73dd577732e3032670090 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 7 Mar 2024 09:05:47 +0300 Subject: [PATCH] fix double init Signed-off-by: Vasiliy Tolstov --- kgo.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kgo.go b/kgo.go index 0197d9a..7d6ad6d 100644 --- a/kgo.go +++ b/kgo.go @@ -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 }