diff --git a/go.mod b/go.mod index dda59b49..72720aea 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible github.com/stretchr/testify v1.5.1 github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844 - github.com/unistack-org/micro-config-cmd v0.0.0-20200920140133-0853deb2e5dc + github.com/unistack-org/micro-config-cmd v0.0.0-20201028144621-5a55f1aad70a golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a golang.org/x/net v0.0.0-20200904194848-62affa334b73 google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d diff --git a/go.sum b/go.sum index 21dc948a..18e27c30 100644 --- a/go.sum +++ b/go.sum @@ -289,9 +289,12 @@ github.com/unistack-org/micro-config-cmd v0.0.0-20200909210755-6e7e85eeab34 h1:V github.com/unistack-org/micro-config-cmd v0.0.0-20200909210755-6e7e85eeab34/go.mod h1:fT1gYn+TtfVZZ5tNx56bZIncJjmlji66g7GKdWua5hE= github.com/unistack-org/micro-config-cmd v0.0.0-20200920140133-0853deb2e5dc h1:hHAU3rgeiA0LaudfNdMLf9/jkOBeFxvJdnwXevviZF8= github.com/unistack-org/micro-config-cmd v0.0.0-20200920140133-0853deb2e5dc/go.mod h1:il8nz4ZEcX3Usyfrtwy+YtQcb7xSUSFJdSe8PBJ9gOA= +github.com/unistack-org/micro-config-cmd v0.0.0-20201028144621-5a55f1aad70a h1:VjlqP1qZkjC0Chmx5MKFPIbtSCigeICFDf8vaLZGh9o= +github.com/unistack-org/micro-config-cmd v0.0.0-20201028144621-5a55f1aad70a/go.mod h1:MzMg+qh1wORZwYtg5AVgFkNFrXVVbdPKW7s/Is+A994= github.com/unistack-org/micro/v3 v3.0.0-20200827083227-aa99378adc6e/go.mod h1:rPQbnry3nboAnMczj8B1Gzlcyv/HYoMZLgd3/3nttJ4= github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200909210629-caec730248b1/go.mod h1:mmqHR9WelHUXqg2mELjsQ+FJHcWs6mNmXg+wEYO2T3c= github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200920135754-1cbd1d2bad83/go.mod h1:HUzMG4Mcy97958VxWTg8zuazZgwQ/aoLZ8wtBVONwRE= +github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200922103357-4c4fa00a5d94/go.mod h1:aL+8VhSXpx0SuEeXPOWUo5BgS7kyvWYobeXFay90UUM= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/options.go b/options.go index 24c6d994..363c3706 100644 --- a/options.go +++ b/options.go @@ -49,8 +49,8 @@ type Options struct { Context context.Context } -func newOptions(opts ...Option) Options { - opt := Options{ +func NewOptions(opts ...Option) Options { + options := Options{ Context: context.Background(), Server: server.DefaultServer, Client: client.DefaultClient, @@ -67,10 +67,10 @@ func newOptions(opts ...Option) Options { } for _, o := range opts { - o(&opt) + o(&options) } - return opt + return options } type Option func(*Options) diff --git a/service.go b/service.go index 4d814f9d..ed9deae3 100644 --- a/service.go +++ b/service.go @@ -5,7 +5,6 @@ import ( rtime "runtime" "sync" - cmd "github.com/unistack-org/micro-config-cmd" "github.com/unistack-org/micro/v3/broker" "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/logger" @@ -22,10 +21,7 @@ type service struct { } func newService(opts ...Option) Service { - options := newOptions(opts...) - - service := &service{opts: options} - + service := &service{opts: NewOptions(opts...)} return service } @@ -37,6 +33,8 @@ func (s *service) Name() string { // which parses command line flags. cmd.Init is only called // on first Init. func (s *service) Init(opts ...Option) error { + //var once sync.Once + // process options for _, o := range opts { o(&s.opts) @@ -48,21 +46,13 @@ func (s *service) Init(opts ...Option) error { s.opts.Cmd.App().Name = s.Server().Options().Name } + //once.Do(func() { // Initialise the command options - if err := s.opts.Cmd.Init( - cmd.Auth(&s.opts.Auth), - cmd.Broker(&s.opts.Broker), - cmd.Registry(&s.opts.Registry), - cmd.Runtime(&s.opts.Runtime), - cmd.Transport(&s.opts.Transport), - cmd.Client(&s.opts.Client), - cmd.Config(&s.opts.Config), - cmd.Server(&s.opts.Server), - cmd.Store(&s.opts.Store), - cmd.Profile(&s.opts.Profile), - ); err != nil { - return err - } + // if err := s.opts.Cmd.Init(); err != nil { + // logger.Fatal(err) + //return err + // } + //}) } if s.opts.Registry != nil {