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:
10
options.go
10
options.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user