Set option and cli args to the service profile (#1259)

This commit is contained in:
Di Wu
2020-02-26 00:42:43 +08:00
committed by GitHub
parent 53c3bff819
commit 603d37b135
5 changed files with 61 additions and 21 deletions

View File

@@ -7,6 +7,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/debug/profile"
"github.com/micro/go-micro/v2/debug/trace"
"github.com/micro/go-micro/v2/registry"
"github.com/micro/go-micro/v2/runtime"
@@ -32,6 +33,7 @@ type Options struct {
Store *store.Store
Tracer *trace.Tracer
Auth *auth.Auth
Profile *profile.Profile
Brokers map[string]func(...broker.Option) broker.Broker
Clients map[string]func(...client.Option) client.Client
@@ -43,6 +45,7 @@ type Options struct {
Stores map[string]func(...store.Option) store.Store
Tracers map[string]func(...trace.Option) trace.Tracer
Auths map[string]func(...auth.Option) auth.Auth
Profiles map[string]func(...profile.Option) profile.Profile
// Other options for implementations of the interface
// can be stored in a context
@@ -118,6 +121,12 @@ func Auth(a *auth.Auth) Option {
}
}
func Profile(p *profile.Profile) Option {
return func(o *Options) {
o.Profile = p
}
}
// New broker func
func NewBroker(name string, b func(...broker.Option) broker.Broker) Option {
return func(o *Options) {