diff --git a/README.md b/README.md index 6fc1bba..71eb89c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# micro-logger-service +# micro-config-service diff --git a/service.go b/service.go index bad82c5..0dc7bad 100644 --- a/service.go +++ b/service.go @@ -6,6 +6,7 @@ import ( "github.com/imdario/mergo" pb "github.com/unistack-org/micro-config-service/v3/proto" + "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/config" rutil "github.com/unistack-org/micro/v3/util/reflect" ) @@ -29,16 +30,26 @@ func (c *serviceConfig) Init(opts ...config.Option) error { o(&c.opts) } + var cli client.Client if c.opts.Context != nil { - if v, ok := c.opts.Context.Value(serviceKey{}).(string); ok { + if v, ok := c.opts.Context.Value(serviceKey{}).(string); ok && v != "" { c.service = v } + if v, ok := c.opts.Context.Value(clientKey{}).(client.Client); ok { + cli = v + } + } + + if cli == nil { + return fmt.Errorf("missing Client option") } if c.service == "" { return fmt.Errorf("missing Service option") } + c.client = pb.NewConfigService(c.service, cli) + return nil }