This commit is contained in:
crusader 2017-11-09 15:47:07 +09:00
parent 16ddb936c5
commit 87a3b25404
4 changed files with 21 additions and 20 deletions

View File

@ -1,4 +1,4 @@
package overflow_grpc_pool package grpc_pool
const ( const (
// DefaultWriteTimeout is default value of Write Timeout // DefaultWriteTimeout is default value of Write Timeout

View File

@ -1,4 +1,4 @@
package overflow_grpc_pool package grpc_pool
import ( import (
"errors" "errors"
@ -95,7 +95,7 @@ func (p *pool) createInstance() error {
return ErrPoolFull return ErrPoolFull
} }
conn, i, err := p.ph.OnCreate() conn, i, err := p.ph.Dial()
if err != nil { if err != nil {
return err return err
} }

View File

@ -1,4 +1,4 @@
package overflow_grpc_pool package grpc_pool
import ( import (
"time" "time"

View File

@ -1,6 +1,7 @@
package overflow_grpc_pool package grpc_pool
import ( import (
"fmt"
"time" "time"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -13,30 +14,30 @@ type PoolHandlers struct {
MaxCapacity int MaxCapacity int
} }
func (h *PoolHandlers) Dial() (*grpc.ClientConn, interface{}, error) { func (ph *PoolHandlers) Dial() (*grpc.ClientConn, interface{}, error) {
return nil, nil, nil return nil, nil, fmt.Errorf("GRPC Pool: Dial method is not implemented")
} }
func (h *PoolHandlers) GetIdleTimeout() time.Duration { func (ph *PoolHandlers) GetIdleTimeout() time.Duration {
return h.IdleTimeout return ph.IdleTimeout
} }
func (h *PoolHandlers) GetMaxIdle() int { func (ph *PoolHandlers) GetMaxIdle() int {
return h.MaxIdle return ph.MaxIdle
} }
func (h *PoolHandlers) GetMaxCapacity() int { func (ph *PoolHandlers) GetMaxCapacity() int {
return h.MaxCapacity return ph.MaxCapacity
} }
// Validate validates the configuration // Validate validates the configuration
func (o *PoolHandlers) Validate() { func (ph *PoolHandlers) Validate() {
if o.IdleTimeout < 0 { if ph.IdleTimeout < 0 {
o.IdleTimeout = DefaultIdleTimeout ph.IdleTimeout = DefaultIdleTimeout
} }
if o.MaxIdle < 0 { if ph.MaxIdle < 0 {
o.MaxIdle = DefaultMaxIdle ph.MaxIdle = DefaultMaxIdle
} }
if o.MaxCapacity <= 0 { if ph.MaxCapacity <= 0 {
o.MaxCapacity = DefaultMaxCapacity ph.MaxCapacity = DefaultMaxCapacity
} }
} }