Skip to content

Commit

Permalink
add config to cmd (micro#1337)
Browse files Browse the repository at this point in the history
* add config to cmd

* fix build
  • Loading branch information
asim committed Mar 12, 2020
1 parent 47f1203 commit d8cfa7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions config/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ type Options struct {
Registry *registry.Registry
Selector *selector.Selector
Transport *transport.Transport
Config *config.Config
Client *client.Client
Server *server.Server
Runtime *runtime.Runtime
Store *store.Store
Tracer *trace.Tracer
Auth *auth.Auth
Profile *profile.Profile
Config *config.Config

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
Registries map[string]func(...registry.Option) registry.Registry
Selectors map[string]func(...selector.Option) selector.Selector
Expand All @@ -48,7 +49,6 @@ type Options struct {
Tracers map[string]func(...trace.Option) trace.Tracer
Auths map[string]func(...auth.Option) auth.Auth
Profiles map[string]func(...profile.Option) profile.Profile
Configs map[string]func(...config.Option) (config.Config, error)

// Other options for implementations of the interface
// can be stored in a context
Expand Down Expand Up @@ -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 {
return func(o *Options) {
o.Selector = s
Expand Down
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ type Options struct {
Auth auth.Auth
Broker broker.Broker
Cmd cmd.Cmd
Config config.Config
Client client.Client
Server server.Server
Registry registry.Registry
Transport transport.Transport
Profile profile.Profile
Config config.Config

// Before and After funcs
BeforeStart []func() error
Expand Down
1 change: 1 addition & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (s *service) Init(opts ...Option) {
cmd.Registry(&s.opts.Registry),
cmd.Transport(&s.opts.Transport),
cmd.Client(&s.opts.Client),
cmd.Config(&s.opts.Config),
cmd.Server(&s.opts.Server),
cmd.Profile(&s.opts.Profile),
); err != nil {
Expand Down

0 comments on commit d8cfa7a

Please sign in to comment.