Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lpxxn/grpc-pool

simple grpc client connection pool
https://github.com/lpxxn/grpc-pool

grpc-go grpc-pool

Last synced: 19 days ago
JSON representation

simple grpc client connection pool

Awesome Lists containing this project

README

        

## simple grpc client connection pool

```
newClient := func() (*grpc.ClientConn, error) {
opts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock()}
return grpc.Dial("your connection address", opts...)
}
pool := NewGrpcPool(newClient, 10, time.Second*30)
con, err := pool.GetConn()
if err != nil {
panic(err)
}
if con.GetState() != connectivity.Ready {
panic("client not ready")
}
con.Release()

pool.CloseAllConn()
```