From 89d804f9e6eceabc98cd9fe50b0e5df632f905a0 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 24 Mar 2021 23:23:53 +0300 Subject: [PATCH] cleanup Signed-off-by: Vasiliy Tolstov --- service.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/service.go b/service.go index e358496..7271f3d 100644 --- a/service.go +++ b/service.go @@ -17,6 +17,7 @@ type serviceBroker struct { addrs []string service string client pbmicro.BrokerClient + init bool opts broker.Options } @@ -33,6 +34,10 @@ func (b *serviceBroker) Disconnect(ctx context.Context) error { } func (b *serviceBroker) Init(opts ...broker.Option) error { + if len(opts) == 0 && b.init { + return nil + } + for _, o := range opts { o(&b.opts) } @@ -47,6 +52,19 @@ func (b *serviceBroker) Init(opts ...broker.Option) error { } } + if err := b.opts.Register.Init(); err != nil { + return err + } + if err := b.opts.Tracer.Init(); err != nil { + return err + } + if err := b.opts.Logger.Init(); err != nil { + return err + } + if err := b.opts.Meter.Init(); err != nil { + return err + } + if b.service == "" { return fmt.Errorf("missing Service option") }