From ec7a22b2dc89174b5b20c7c43f2c972cd31cefd7 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 7 Mar 2024 09:06:33 +0300 Subject: [PATCH] fix double init Signed-off-by: Vasiliy Tolstov --- kgo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kgo.go b/kgo.go index 97415b2..24b8e56 100644 --- a/kgo.go +++ b/kgo.go @@ -54,6 +54,7 @@ var DefaultRetryBackoffFn = func() func(int) time.Duration { }() type Broker struct { + init bool c *kgo.Client kopts []kgo.Opt connected bool @@ -182,6 +183,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) } @@ -205,6 +210,8 @@ func (k *Broker) Init(opts ...broker.Option) error { } } + k.init = true + return nil }