Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-03-24 23:23:53 +03:00
parent 6998184d9e
commit 89d804f9e6

View File

@ -17,6 +17,7 @@ type serviceBroker struct {
addrs []string addrs []string
service string service string
client pbmicro.BrokerClient client pbmicro.BrokerClient
init bool
opts broker.Options opts broker.Options
} }
@ -33,6 +34,10 @@ func (b *serviceBroker) Disconnect(ctx context.Context) error {
} }
func (b *serviceBroker) Init(opts ...broker.Option) error { func (b *serviceBroker) Init(opts ...broker.Option) error {
if len(opts) == 0 && b.init {
return nil
}
for _, o := range opts { for _, o := range opts {
o(&b.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 == "" { if b.service == "" {
return fmt.Errorf("missing Service option") return fmt.Errorf("missing Service option")
} }