mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-23 21:44:41 +02:00
Better connection pool handling (#2725)
* [fix] etcd config source prefix issue (#2389) * http transport data race issue (#2436) * [fix] #2431 http transport data race issue * [feature] Ability to close connection while receiving. Ability to send messages while receiving. Icreased r channel limit to 100 to more fluently communication. Do not dropp sent request if r channel is full. * [fix] Use pool connection close timeout * [fix] replace Close with private function * [fix] Do not close the transport client twice in stream connection , the transport client is closed in the rpc codec * [fix] tests --------- Co-authored-by: Johnson C <chengqiaosheng@gmail.com>
This commit is contained in:
@@ -27,6 +27,8 @@ var (
|
||||
DefaultPoolSize = 100
|
||||
// DefaultPoolTTL sets the connection pool ttl.
|
||||
DefaultPoolTTL = time.Minute
|
||||
// DefaultPoolCloseTimeout sets the connection pool colse timeout.
|
||||
DefaultPoolCloseTimeout = time.Second
|
||||
)
|
||||
|
||||
// Options are the Client options.
|
||||
@@ -63,8 +65,9 @@ type Options struct {
|
||||
Wrappers []Wrapper
|
||||
|
||||
// Connection Pool
|
||||
PoolSize int
|
||||
PoolTTL time.Duration
|
||||
PoolSize int
|
||||
PoolTTL time.Duration
|
||||
PoolCloseTimeout time.Duration
|
||||
}
|
||||
|
||||
// CallOptions are options used to make calls to a server.
|
||||
@@ -140,13 +143,14 @@ func NewOptions(options ...Option) Options {
|
||||
ConnectionTimeout: DefaultConnectionTimeout,
|
||||
DialTimeout: transport.DefaultDialTimeout,
|
||||
},
|
||||
PoolSize: DefaultPoolSize,
|
||||
PoolTTL: DefaultPoolTTL,
|
||||
Broker: broker.DefaultBroker,
|
||||
Selector: selector.DefaultSelector,
|
||||
Registry: registry.DefaultRegistry,
|
||||
Transport: transport.DefaultTransport,
|
||||
Logger: logger.DefaultLogger,
|
||||
PoolSize: DefaultPoolSize,
|
||||
PoolTTL: DefaultPoolTTL,
|
||||
PoolCloseTimeout: DefaultPoolCloseTimeout,
|
||||
Broker: broker.DefaultBroker,
|
||||
Selector: selector.DefaultSelector,
|
||||
Registry: registry.DefaultRegistry,
|
||||
Transport: transport.DefaultTransport,
|
||||
Logger: logger.DefaultLogger,
|
||||
}
|
||||
|
||||
for _, o := range options {
|
||||
@@ -191,6 +195,13 @@ func PoolTTL(d time.Duration) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// PoolCloseTimeout sets the connection pool close timeout.
|
||||
func PoolCloseTimeout(d time.Duration) Option {
|
||||
return func(o *Options) {
|
||||
o.PoolCloseTimeout = d
|
||||
}
|
||||
}
|
||||
|
||||
// Registry to find nodes for a given service.
|
||||
func Registry(r registry.Registry) Option {
|
||||
return func(o *Options) {
|
||||
|
||||
Reference in New Issue
Block a user