Add the ability to switch out client/server
This commit is contained in:
@@ -26,8 +26,10 @@ type Options struct {
|
||||
Server *server.Server
|
||||
|
||||
Brokers map[string]func(...broker.Option) broker.Broker
|
||||
Clients map[string]func(...client.Option) client.Client
|
||||
Registries map[string]func(...registry.Option) registry.Registry
|
||||
Selectors map[string]func(...selector.Option) selector.Selector
|
||||
Servers map[string]func(...server.Option) server.Server
|
||||
Transports map[string]func(...transport.Option) transport.Transport
|
||||
|
||||
// Other options for implementations of the interface
|
||||
@@ -99,6 +101,13 @@ func NewBroker(name string, b func(...broker.Option) broker.Broker) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// New client func
|
||||
func NewClient(name string, b func(...client.Option) client.Client) Option {
|
||||
return func(o *Options) {
|
||||
o.Clients[name] = b
|
||||
}
|
||||
}
|
||||
|
||||
// New registry func
|
||||
func NewRegistry(name string, r func(...registry.Option) registry.Registry) Option {
|
||||
return func(o *Options) {
|
||||
@@ -113,6 +122,13 @@ func NewSelector(name string, s func(...selector.Option) selector.Selector) Opti
|
||||
}
|
||||
}
|
||||
|
||||
// New server func
|
||||
func NewServer(name string, s func(...server.Option) server.Server) Option {
|
||||
return func(o *Options) {
|
||||
o.Servers[name] = s
|
||||
}
|
||||
}
|
||||
|
||||
// New transport func
|
||||
func NewTransport(name string, t func(...transport.Option) transport.Transport) Option {
|
||||
return func(o *Options) {
|
||||
|
||||
Reference in New Issue
Block a user