Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-03-24 23:25:36 +03:00
parent 48379bc825
commit 938f3b65da

20
stan.go
View File

@ -25,6 +25,7 @@ type stanBroker struct {
clientID string clientID string
connectTimeout time.Duration connectTimeout time.Duration
connectRetry bool connectRetry bool
init bool
done chan struct{} done chan struct{}
ctx context.Context ctx context.Context
} }
@ -262,10 +263,29 @@ func (n *stanBroker) Disconnect(ctx context.Context) error {
} }
func (n *stanBroker) Init(opts ...broker.Option) 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 { for _, o := range opts {
o(&n.opts) o(&n.opts)
} }
n.addrs = setAddrs(n.opts.Addrs) n.addrs = setAddrs(n.opts.Addrs)
n.init = true
return nil return nil
} }