https://github.com/dudebing99/grpc-connection-pool
grpc client connection pool
https://github.com/dudebing99/grpc-connection-pool
grpc grpc-client-connection-pool grpc-client-pool grpc-connection-pool pool
Last synced: about 1 year ago
JSON representation
grpc client connection pool
- Host: GitHub
- URL: https://github.com/dudebing99/grpc-connection-pool
- Owner: dudebing99
- License: mit
- Created: 2020-12-30T14:01:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-03-11T09:27:16.000Z (about 4 years ago)
- Last Synced: 2025-01-30T20:39:11.124Z (about 1 year ago)
- Topics: grpc, grpc-client-connection-pool, grpc-client-pool, grpc-connection-pool, pool
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Usage
```bash
go get github.com/dudebing99/grpc-connection-pool
```
# Example
```go
package main
import (
"context"
"fmt"
rpc "github.com/dudebing99/grpc-connection-pool"
)
func main() {
pool, err := rpc.NewRpcClientPool(rpc.WithServerAddr("0.0.0.0:8080"))
if err != nil {
fmt.Println("init client pool error")
return
}
clientConn, close, err := pool.Acquire()
defer close()
if err != nil {
fmt.Println("acquire client connection error")
return
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
reply, err := NewGreeterClient(clientConn).SayHello(ctx, &HelloRequest{Name: "SillyBoy"})
if err != nil {
fmt.Println("say hello error, ", err)
return
}
fmt.Println(reply.Message)
}
```