update for latest micro changes #98

Merged
vtolstov merged 1 commits from microv4 into master 2023-08-14 23:45:41 +03:00
3 changed files with 17 additions and 9 deletions

11
env.go
View File

@ -10,6 +10,7 @@ import (
"github.com/imdario/mergo" "github.com/imdario/mergo"
"go.unistack.org/micro/v4/config" "go.unistack.org/micro/v4/config"
"go.unistack.org/micro/v4/options"
rutil "go.unistack.org/micro/v4/util/reflect" rutil "go.unistack.org/micro/v4/util/reflect"
) )
@ -23,7 +24,7 @@ func (c *envConfig) Options() config.Options {
return c.opts return c.opts
} }
func (c *envConfig) Init(opts ...config.Option) error { func (c *envConfig) Init(opts ...options.Option) error {
for _, o := range opts { for _, o := range opts {
o(&c.opts) o(&c.opts)
} }
@ -39,7 +40,7 @@ func (c *envConfig) Init(opts ...config.Option) error {
return nil return nil
} }
func (c *envConfig) Load(ctx context.Context, opts ...config.LoadOption) error { func (c *envConfig) Load(ctx context.Context, opts ...options.Option) error {
if err := config.DefaultBeforeLoad(ctx, c); err != nil && !c.opts.AllowFail { if err := config.DefaultBeforeLoad(ctx, c); err != nil && !c.opts.AllowFail {
return err return err
} }
@ -315,7 +316,7 @@ func fillValues(ctx context.Context, valueOf reflect.Value, structTag string) er
return nil return nil
} }
func (c *envConfig) Save(ctx context.Context, opts ...config.SaveOption) error { func (c *envConfig) Save(ctx context.Context, opts ...options.Option) error {
options := config.NewSaveOptions(opts...) options := config.NewSaveOptions(opts...)
if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail { if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail {
@ -346,7 +347,7 @@ func (c *envConfig) Name() string {
return c.opts.Name return c.opts.Name
} }
func (c *envConfig) Watch(ctx context.Context, opts ...config.WatchOption) (config.Watcher, error) { func (c *envConfig) Watch(ctx context.Context, opts ...options.Option) (config.Watcher, error) {
w := &envWatcher{ w := &envWatcher{
opts: c.opts, opts: c.opts,
wopts: config.NewWatchOptions(opts...), wopts: config.NewWatchOptions(opts...),
@ -360,7 +361,7 @@ func (c *envConfig) Watch(ctx context.Context, opts ...config.WatchOption) (conf
return w, nil return w, nil
} }
func NewConfig(opts ...config.Option) config.Config { func NewConfig(opts ...options.Option) config.Config {
options := config.NewOptions(opts...) options := config.NewOptions(opts...)
if len(options.StructTag) == 0 { if len(options.StructTag) == 0 {
options.StructTag = DefaultStructTag options.StructTag = DefaultStructTag

6
go.mod
View File

@ -3,6 +3,8 @@ module go.unistack.org/micro-config-env/v4
go 1.20 go 1.20
require ( require (
github.com/imdario/mergo v0.3.14 github.com/imdario/mergo v0.3.16
go.unistack.org/micro/v4 v4.0.1 go.unistack.org/micro/v4 v4.0.6
) )
require github.com/google/uuid v1.3.0 // indirect

9
go.sum
View File

@ -1,7 +1,12 @@
github.com/imdario/mergo v0.3.14 h1:fOqeC1+nCuuk6PKQdg9YmosXX7Y7mHX6R/0ZldI9iHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/imdario/mergo v0.3.14/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo= go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo=
go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs= go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs=
go.unistack.org/micro/v4 v4.0.6 h1:YFWvTh3VwyOd6NHYTQcf47n2TF5+p/EhpnbuBQX3qhk=
go.unistack.org/micro/v4 v4.0.6/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=