Make pool configurable

This commit is contained in:
Asim
2016-06-07 00:46:14 +01:00
parent 38a66817e6
commit 89401cbb95
5 changed files with 67 additions and 14 deletions

View File

@@ -23,6 +23,10 @@ type Options struct {
Selector selector.Selector
Transport transport.Transport
// Connection Pool
PoolSize int
PoolTTL time.Duration
// Middleware for client
Wrappers []Wrapper
@@ -74,6 +78,8 @@ func newOptions(options ...Option) Options {
RequestTimeout: DefaultRequestTimeout,
DialTimeout: transport.DefaultDialTimeout,
},
PoolSize: DefaultPoolSize,
PoolTTL: DefaultPoolTTL,
}
for _, o := range options {
@@ -126,6 +132,20 @@ func ContentType(ct string) Option {
}
}
// PoolSize sets the connection pool size
func PoolSize(d int) Option {
return func(o *Options) {
o.PoolSize = d
}
}
// PoolSize sets the connection pool size
func PoolTTL(d time.Duration) Option {
return func(o *Options) {
o.PoolTTL = d
}
}
// Registry to find nodes for a given service
func Registry(r registry.Registry) Option {
return func(o *Options) {