Categorygithub.com/wuxinwei/grpcpool
modulepackage
1.1.1
Repository: https://github.com/wuxinwei/grpcpool.git
Documentation: pkg.go.dev

# README

gRPC Connection Pool

Build Status Go Report Card codecov

It's a simple implement of grpc connection pool, based on buffered channel.

Requirement

  • Go 1.9+

Usage

import "github.com/wuxinwei/grpcpool"

// create a grpc pool
sa := ServiceArg
Create(grpc.Dial, 5, 10, sa)

// got a connection from pool, and create a grpc client
conn, _ := grpcpool.Get()
cli := pb.NewHelloClient(conn)

// do whatever you want with grpc client

// after you finish your work, remember to put the conn back into the pool
grpcpool.PutBack(conn)

// you can close your pool do your own purpose
grpcpool.Close()

# Functions

Close the gRPC pool totally.
Create a bundle of connection pool instance.
Get is that try to get a grpc connection from grpc pool by specified service name.
Len is that get length of specific grpc service connection pool.
PutBack is that give back a specific gRPC service connection to gRPC pool.

# Structs

ServiceArg is that specified gRPC service configuration.

# Type aliases

ConnGenerator is function type to generate a grpc connection function.