modulepackage
0.0.0-20220928145230-238f313429cc
Repository: https://github.com/isayme/go-grpcpool.git
Documentation: pkg.go.dev
# README
Pool
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.
Getting started
Install
Import package:
import (
pool "github.com/isayme/go-grpcpool"
)
go get github.com/isayme/go-grpcpool
Usage
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/isayme/go-grpcpool/tree/master/example
Reference
License
Pool is under the Apache 2.0 license. See the LICENSE file for details.
# Packages
No description provided by the author
# Constants
BackoffMaxDelay provided maximum delay when backing off after failed connection attempts.
DialTimeout the timeout of create connection.
InitialConnWindowSize we set it 1GB is to provide system's throughput.
InitialWindowSize we set it 1GB is to provide system's throughput.
KeepAliveTime is the duration of time after which if the client doesn't see any activity it pings the server to see if the transport is still alive.
KeepAliveTimeout is the duration of time for which the client waits after having pinged for keepalive check and if no activity is seen even after that the connection is closed.
MaxRecvMsgSize set max gRPC receive message size received from server.
MaxSendMsgSize set max gRPC request message size sent to server.
# Variables
DefaultOptions sets a list of recommended options for good performance.
ErrClosed is the error resulting if the pool is closed via pool.Close().