Add Config to service options (#1336)

Co-authored-by: Ben Toogood <ben@micro.mu>
Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
ben-toogood
2020-03-12 18:13:03 +00:00
committed by GitHub
parent 1b4e881d74
commit 47f1203e97
6 changed files with 60 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/micro/go-micro/v2/broker"
"github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/client/selector"
"github.com/micro/go-micro/v2/config"
"github.com/micro/go-micro/v2/config/cmd"
"github.com/micro/go-micro/v2/debug/profile"
"github.com/micro/go-micro/v2/debug/trace"
@@ -27,6 +28,7 @@ type Options struct {
Registry registry.Registry
Transport transport.Transport
Profile profile.Profile
Config config.Config
// Before and After funcs
BeforeStart []func() error
@@ -46,6 +48,7 @@ func newOptions(opts ...Option) Options {
Auth: auth.DefaultAuth,
Broker: broker.DefaultBroker,
Cmd: cmd.DefaultCmd,
Config: config.DefaultConfig,
Client: client.DefaultClient,
Server: server.DefaultServer,
Registry: registry.DefaultRegistry,
@@ -143,6 +146,13 @@ func Auth(a auth.Auth) Option {
}
}
// Config sets the config for the service
func Config(c config.Config) Option {
return func(o *Options) {
o.Config = c
}
}
// Selector sets the selector for the service client
func Selector(s selector.Selector) Option {
return func(o *Options) {