1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-18 22:17:44 +02:00

[feature] stream CloseSend (#2323)

* support stream CloseSend

* move CloseSend into Closer
This commit is contained in:
Johnson C
2021-10-26 22:07:08 +08:00
committed by GitHub
parent af3cfa0a4c
commit d2a51d05c4
29 changed files with 2378 additions and 391 deletions

View File

@ -1,6 +1,7 @@
package grpc
import (
"context"
"sync"
"time"
@ -66,7 +67,7 @@ func newPool(size int, ttl time.Duration, idle int, ms int) *pool {
}
}
func (p *pool) getConn(addr string, opts ...grpc.DialOption) (*poolConn, error) {
func (p *pool) getConn(dialCtx context.Context, addr string, opts ...grpc.DialOption) (*poolConn, error) {
now := time.Now().Unix()
p.Lock()
sp, ok := p.conns[addr]
@ -135,7 +136,7 @@ func (p *pool) getConn(addr string, opts ...grpc.DialOption) (*poolConn, error)
p.Unlock()
// create new conn
cc, err := grpc.Dial(addr, opts...)
cc, err := grpc.DialContext(dialCtx, addr, opts...)
if err != nil {
return nil, err
}
@ -184,7 +185,6 @@ func (p *pool) release(addr string, conn *poolConn, err error) {
sp.idle++
}
p.Unlock()
return
}
func (conn *poolConn) Close() {