aboutsummaryrefslogtreecommitdiff
path: root/weed/pb/grpc_client_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/pb/grpc_client_server.go')
-rw-r--r--weed/pb/grpc_client_server.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/weed/pb/grpc_client_server.go b/weed/pb/grpc_client_server.go
index fac8adcb3..15dc917e9 100644
--- a/weed/pb/grpc_client_server.go
+++ b/weed/pb/grpc_client_server.go
@@ -213,6 +213,21 @@ func WithMasterClient(master string, grpcDialOption grpc.DialOption, fn func(cli
}
+func WithOneOfGrpcMasterClients(masterGrpcAddresses []string, grpcDialOption grpc.DialOption, fn func(client master_pb.SeaweedClient) error) (err error) {
+
+ for _, masterGrpcAddress := range masterGrpcAddresses {
+ err = WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
+ client := master_pb.NewSeaweedClient(grpcConnection)
+ return fn(client)
+ }, masterGrpcAddress, grpcDialOption)
+ if err == nil {
+ return nil
+ }
+ }
+
+ return err
+}
+
func WithBrokerGrpcClient(brokerGrpcAddress string, grpcDialOption grpc.DialOption, fn func(client messaging_pb.SeaweedMessagingClient) error) error {
return WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {