Add the ability to switch out client/server

This commit is contained in:
Asim
2016-11-18 17:29:26 +00:00
parent f9709ffa6e
commit 20feb95e18
6 changed files with 60 additions and 9 deletions

View File

@@ -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) {