Connection pool for Go's grpc client that supports connection reuse.
Pool provides additional features:
Connection reuse
supported by specific MaxConcurrentStreams param.Failure reconnection
supported by grpc's keepalive.
Import package:
import (
"github.com/shimingyah/pool"
)
go get github.com/shimingyah/pool
p, err := pool.New("127.0.0.1:8080", pool.DefaultOptions)
if err != nil {
log.Fatalf("failed to new pool: %v", err)
}
defer p.Close()
conn, err := p.Get()
if err != nil {
log.Fatalf("failed to get conn: %v", err)
}
defer conn.Close()
// cc := conn.Value()
// client := pb.NewClient(conn.Value())
See the complete example: https://github.com/shimingyah/pool/tree/master/example
Pool is under the Apache 2.0 license. See the LICENSE file for details.