add config to cmd (#1337)

* add config to cmd

* fix build
This commit is contained in:
Asim Aslam 2020-03-12 18:47:40 +00:00 committed by GitHub
parent 47f1203e97
commit d8cfa7a295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -28,6 +28,7 @@ type Options struct {
Registry *registry.Registry Registry *registry.Registry
Selector *selector.Selector Selector *selector.Selector
Transport *transport.Transport Transport *transport.Transport
Config *config.Config
Client *client.Client Client *client.Client
Server *server.Server Server *server.Server
Runtime *runtime.Runtime Runtime *runtime.Runtime
@ -35,9 +36,9 @@ type Options struct {
Tracer *trace.Tracer Tracer *trace.Tracer
Auth *auth.Auth Auth *auth.Auth
Profile *profile.Profile Profile *profile.Profile
Config *config.Config
Brokers map[string]func(...broker.Option) broker.Broker Brokers map[string]func(...broker.Option) broker.Broker
Configs map[string]func(...config.Option) (config.Config, error)
Clients map[string]func(...client.Option) client.Client Clients map[string]func(...client.Option) client.Client
Registries map[string]func(...registry.Option) registry.Registry Registries map[string]func(...registry.Option) registry.Registry
Selectors map[string]func(...selector.Option) selector.Selector Selectors map[string]func(...selector.Option) selector.Selector
@ -48,7 +49,6 @@ type Options struct {
Tracers map[string]func(...trace.Option) trace.Tracer Tracers map[string]func(...trace.Option) trace.Tracer
Auths map[string]func(...auth.Option) auth.Auth Auths map[string]func(...auth.Option) auth.Auth
Profiles map[string]func(...profile.Option) profile.Profile Profiles map[string]func(...profile.Option) profile.Profile
Configs map[string]func(...config.Option) (config.Config, error)
// Other options for implementations of the interface // Other options for implementations of the interface
// can be stored in a context // can be stored in a context
@ -82,6 +82,12 @@ func Broker(b *broker.Broker) Option {
} }
} }
func Config(c *config.Config) Option {
return func(o *Options) {
o.Config = c
}
}
func Selector(s *selector.Selector) Option { func Selector(s *selector.Selector) Option {
return func(o *Options) { return func(o *Options) {
o.Selector = s o.Selector = s

View File

@ -23,12 +23,12 @@ type Options struct {
Auth auth.Auth Auth auth.Auth
Broker broker.Broker Broker broker.Broker
Cmd cmd.Cmd Cmd cmd.Cmd
Config config.Config
Client client.Client Client client.Client
Server server.Server Server server.Server
Registry registry.Registry Registry registry.Registry
Transport transport.Transport Transport transport.Transport
Profile profile.Profile Profile profile.Profile
Config config.Config
// Before and After funcs // Before and After funcs
BeforeStart []func() error BeforeStart []func() error

View File

@ -99,6 +99,7 @@ func (s *service) Init(opts ...Option) {
cmd.Registry(&s.opts.Registry), cmd.Registry(&s.opts.Registry),
cmd.Transport(&s.opts.Transport), cmd.Transport(&s.opts.Transport),
cmd.Client(&s.opts.Client), cmd.Client(&s.opts.Client),
cmd.Config(&s.opts.Config),
cmd.Server(&s.opts.Server), cmd.Server(&s.opts.Server),
cmd.Profile(&s.opts.Profile), cmd.Profile(&s.opts.Profile),
); err != nil { ); err != nil {