43 lines
790 B
Go
43 lines
790 B
Go
package overflow_grpc_pool
|
|
|
|
import (
|
|
"time"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// Options is configuration of the Pool of GRpc client
|
|
type PoolHandlers struct {
|
|
IdleTimeout time.Duration
|
|
MaxIdle int
|
|
MaxCapacity int
|
|
}
|
|
|
|
func (h *PoolHandlers) Dial() (*grpc.ClientConn, interface{}, error) {
|
|
return nil, nil, nil
|
|
}
|
|
|
|
func (h *PoolHandlers) GetIdleTimeout() time.Duration {
|
|
return h.IdleTimeout
|
|
}
|
|
func (h *PoolHandlers) GetMaxIdle() int {
|
|
return h.MaxIdle
|
|
}
|
|
func (h *PoolHandlers) GetMaxCapacity() int {
|
|
return h.MaxCapacity
|
|
}
|
|
|
|
// Validate validates the configuration
|
|
func (o *PoolHandlers) Validate() {
|
|
if o.IdleTimeout < 0 {
|
|
o.IdleTimeout = DefaultIdleTimeout
|
|
}
|
|
if o.MaxIdle < 0 {
|
|
o.MaxIdle = DefaultMaxIdle
|
|
}
|
|
if o.MaxCapacity <= 0 {
|
|
o.MaxCapacity = DefaultMaxCapacity
|
|
}
|
|
|
|
}
|