Documentation
¶
Overview ¶
Package grpc_connection_pool provides the ability to create connection pool for gRPC.
Here is example to create connection pool:
// Create Options object
options := &pool.Options{
InitCap: 8,
MaxCap: 16,
DialTimeout: time.Second * 20,
}
// Create connection pool with options
pool, err := grpc_connection_pool.NewGRPCPool("localhost:8888", options, grpc.WithInsecure())
if err != nil {
log.Println(err)
return
}
// Get a available gRPC client
client := pool.Get()
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrExceeded = errors.New("Maximum number of connections exceeded")
ErrExceeded is the error when maximum number of connections exceeded
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(c *grpc.ClientConn) *Connection
type GRPCPool ¶
type GRPCPool struct {
// contains filtered or unexported fields
}
func NewGRPCPool ¶
NewGRPCPool creates a new connection pool.
func (*GRPCPool) Get ¶
func (pool *GRPCPool) Get() (*grpc.ClientConn, error)
Get will returns a available gRPC client.
Click to show internal directories.
Click to hide internal directories.