aboutsummaryrefslogtreecommitdiff
path: root/weed/util/grpc_client_server.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-26 14:42:11 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-26 14:42:11 -0800
commit72a64a5cf8c2a5adfe59665a746e013ca948e681 (patch)
treea0fd30cd09d5f6f5a4f8031818f1b12bf7b85f4f /weed/util/grpc_client_server.go
parent0c298ef8906816b40b19db36be673af564af032a (diff)
downloadseaweedfs-72a64a5cf8c2a5adfe59665a746e013ca948e681.tar.xz
seaweedfs-72a64a5cf8c2a5adfe59665a746e013ca948e681.zip
use the same context object in order to retry
Diffstat (limited to 'weed/util/grpc_client_server.go')
-rw-r--r--weed/util/grpc_client_server.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/weed/util/grpc_client_server.go b/weed/util/grpc_client_server.go
index 63519d97a..7e396342b 100644
--- a/weed/util/grpc_client_server.go
+++ b/weed/util/grpc_client_server.go
@@ -57,14 +57,14 @@ func GrpcDial(ctx context.Context, address string, opts ...grpc.DialOption) (*gr
return grpc.DialContext(ctx, address, options...)
}
-func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error, address string, opts ...grpc.DialOption) error {
+func WithCachedGrpcClient(ctx context.Context, fn func(context.Context, *grpc.ClientConn) error, address string, opts ...grpc.DialOption) error {
grpcClientsLock.Lock()
existingConnection, found := grpcClients[address]
if found {
grpcClientsLock.Unlock()
- err := fn(existingConnection)
+ err := fn(ctx, existingConnection)
if err != nil {
grpcClientsLock.Lock()
delete(grpcClients, address)
@@ -83,7 +83,7 @@ func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error,
grpcClients[address] = grpcConnection
grpcClientsLock.Unlock()
- err = fn(grpcConnection)
+ err = fn(ctx, grpcConnection)
if err != nil {
grpcClientsLock.Lock()
delete(grpcClients, address)