grpc_pool/pool_handlers.go
2017-09-05 14:42:54 +09:00

42 lines
793 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) GetIdleTimeout() time.Duration {
return h.IdleTimeout
}
func (h *PoolHandlers) GetMaxIdle() int {
return h.MaxIdle
}
func (h *PoolHandlers) GetMaxCapacity() int {
return h.MaxCapacity
}
func (h *PoolHandlers) OnCreate() (*grpc.ClientConn, interface{}, error) {
return nil, nil, nil
}
// 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
}
}