From 938f3b65da3a2b1e27fc301c820a77510d8d7805 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 24 Mar 2021 23:25:36 +0300 Subject: [PATCH] cleanup Signed-off-by: Vasiliy Tolstov --- stan.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/stan.go b/stan.go index 87b1225..b0eebfe 100644 --- a/stan.go +++ b/stan.go @@ -25,6 +25,7 @@ type stanBroker struct { clientID string connectTimeout time.Duration connectRetry bool + init bool done chan struct{} ctx context.Context } @@ -262,10 +263,29 @@ func (n *stanBroker) Disconnect(ctx context.Context) error { } func (n *stanBroker) Init(opts ...broker.Option) error { + if len(opts) == 0 && n.init { + return nil + } + + if err := n.opts.Register.Init(); err != nil { + return err + } + if err := n.opts.Tracer.Init(); err != nil { + return err + } + if err := n.opts.Logger.Init(); err != nil { + return err + } + if err := n.opts.Meter.Init(); err != nil { + return err + } + for _, o := range opts { o(&n.opts) } n.addrs = setAddrs(n.opts.Addrs) + + n.init = true return nil }