mirror of
https://github.com/go-micro/go-micro.git
synced 2025-07-12 22:41:07 +02:00
Plugins and profiles (#2764)
* feat: more plugins * chore(ci): split out benchmarks Attempt to resolve too many open files in ci * chore(ci): split out benchmarks * fix(ci): Attempt to resolve too many open files in ci * fix: set DefaultX for cli flag and service option * fix: restore http broker * fix: default http broker * feat: full nats profile * chore: still ugly, not ready * fix: better initialization for profiles * fix(tests): comment out flaky listen tests * fix: disable benchmarks on gha * chore: cleanup, comments * chore: add nats config source
This commit is contained in:
@ -21,22 +21,22 @@ type Options struct {
|
||||
|
||||
// Other options for implementations of the interface
|
||||
// can be stored in a context
|
||||
Context context.Context
|
||||
Auth *auth.Auth
|
||||
Selector *selector.Selector
|
||||
Profile *profile.Profile
|
||||
Context context.Context
|
||||
Auth *auth.Auth
|
||||
Selector *selector.Selector
|
||||
DebugProfile *profile.Profile
|
||||
|
||||
Registry *registry.Registry
|
||||
|
||||
Brokers map[string]func(...broker.Option) broker.Broker
|
||||
Transport *transport.Transport
|
||||
Cache *cache.Cache
|
||||
Config *config.Config
|
||||
Client *client.Client
|
||||
Server *server.Server
|
||||
Caches map[string]func(...cache.Option) cache.Cache
|
||||
Tracer *trace.Tracer
|
||||
Profiles map[string]func(...profile.Option) profile.Profile
|
||||
Brokers map[string]func(...broker.Option) broker.Broker
|
||||
Transport *transport.Transport
|
||||
Cache *cache.Cache
|
||||
Config *config.Config
|
||||
Client *client.Client
|
||||
Server *server.Server
|
||||
Caches map[string]func(...cache.Option) cache.Cache
|
||||
Tracer *trace.Tracer
|
||||
DebugProfiles map[string]func(...profile.Option) profile.Profile
|
||||
|
||||
// We need pointers to things so we can swap them out if needed.
|
||||
Broker *broker.Broker
|
||||
@ -81,72 +81,84 @@ func Version(v string) Option {
|
||||
func Broker(b *broker.Broker) Option {
|
||||
return func(o *Options) {
|
||||
o.Broker = b
|
||||
broker.DefaultBroker = *b
|
||||
}
|
||||
}
|
||||
|
||||
func Cache(c *cache.Cache) Option {
|
||||
return func(o *Options) {
|
||||
o.Cache = c
|
||||
cache.DefaultCache = *c
|
||||
}
|
||||
}
|
||||
|
||||
func Config(c *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = c
|
||||
config.DefaultConfig = *c
|
||||
}
|
||||
}
|
||||
|
||||
func Selector(s *selector.Selector) Option {
|
||||
return func(o *Options) {
|
||||
o.Selector = s
|
||||
selector.DefaultSelector = *s
|
||||
}
|
||||
}
|
||||
|
||||
func Registry(r *registry.Registry) Option {
|
||||
return func(o *Options) {
|
||||
o.Registry = r
|
||||
registry.DefaultRegistry = *r
|
||||
}
|
||||
}
|
||||
|
||||
func Transport(t *transport.Transport) Option {
|
||||
return func(o *Options) {
|
||||
o.Transport = t
|
||||
transport.DefaultTransport = *t
|
||||
}
|
||||
}
|
||||
|
||||
func Client(c *client.Client) Option {
|
||||
return func(o *Options) {
|
||||
o.Client = c
|
||||
client.DefaultClient = *c
|
||||
}
|
||||
}
|
||||
|
||||
func Server(s *server.Server) Option {
|
||||
return func(o *Options) {
|
||||
o.Server = s
|
||||
server.DefaultServer = *s
|
||||
}
|
||||
}
|
||||
|
||||
func Store(s *store.Store) Option {
|
||||
return func(o *Options) {
|
||||
o.Store = s
|
||||
store.DefaultStore = *s
|
||||
}
|
||||
}
|
||||
|
||||
func Tracer(t *trace.Tracer) Option {
|
||||
return func(o *Options) {
|
||||
o.Tracer = t
|
||||
trace.DefaultTracer = *t
|
||||
}
|
||||
}
|
||||
|
||||
func Auth(a *auth.Auth) Option {
|
||||
return func(o *Options) {
|
||||
o.Auth = a
|
||||
auth.DefaultAuth = *a
|
||||
}
|
||||
}
|
||||
|
||||
func Profile(p *profile.Profile) Option {
|
||||
return func(o *Options) {
|
||||
o.Profile = p
|
||||
o.DebugProfile = p
|
||||
profile.DefaultProfile = *p
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,6 +235,6 @@ func NewConfig(name string, t func(...config.Option) (config.Config, error)) Opt
|
||||
// New profile func.
|
||||
func NewProfile(name string, t func(...profile.Option) profile.Profile) Option {
|
||||
return func(o *Options) {
|
||||
o.Profiles[name] = t
|
||||
o.DebugProfiles[name] = t
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user