aboutsummaryrefslogtreecommitdiff
path: root/weed/util
diff options
context:
space:
mode:
authorChris Lu <chris.lu@uber.com>2019-03-19 05:47:41 -0700
committerChris Lu <chris.lu@uber.com>2019-03-19 05:47:41 -0700
commitda871896c345372780c35de7364b42d910935c53 (patch)
tree32a8bf8419c3533a5d59ab194a2a6dcc664c95b2 /weed/util
parent916b809c086e94208eabe2af1086bcb1289ed298 (diff)
downloadseaweedfs-da871896c345372780c35de7364b42d910935c53.tar.xz
seaweedfs-da871896c345372780c35de7364b42d910935c53.zip
weed filer: set grpc port to port + 10000
Diffstat (limited to 'weed/util')
-rw-r--r--weed/util/grpc_client_server.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/weed/util/grpc_client_server.go b/weed/util/grpc_client_server.go
index 361d245b8..e5993aeab 100644
--- a/weed/util/grpc_client_server.go
+++ b/weed/util/grpc_client_server.go
@@ -81,7 +81,7 @@ func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error,
return err
}
-func ParseServerToGrpcAddress(server string, optionalGrpcPort int) (serverGrpcAddress string, err error) {
+func ParseServerToGrpcAddress(server string) (serverGrpcAddress string, err error) {
hostnameAndPort := strings.Split(server, ":")
if len(hostnameAndPort) != 2 {
return "", fmt.Errorf("server should have hostname:port format: %v", hostnameAndPort)
@@ -93,22 +93,19 @@ func ParseServerToGrpcAddress(server string, optionalGrpcPort int) (serverGrpcAd
}
grpcPort := int(port) + 10000
- if optionalGrpcPort != 0 {
- grpcPort = optionalGrpcPort
- }
return fmt.Sprintf("%s:%d", hostnameAndPort[0], grpcPort), nil
}
-func ServerToGrpcAddress(server string, defaultGrpcPort int) (serverGrpcAddress string) {
+func ServerToGrpcAddress(server string) (serverGrpcAddress string) {
hostnameAndPort := strings.Split(server, ":")
if len(hostnameAndPort) != 2 {
- return fmt.Sprintf("%s:%d", server, defaultGrpcPort)
+ return fmt.Sprintf("unexpected server address: %s", server)
}
port, parseErr := strconv.ParseUint(hostnameAndPort[1], 10, 64)
if parseErr != nil {
- return fmt.Sprintf("%s:%d", hostnameAndPort[0], defaultGrpcPort)
+ return fmt.Sprintf("failed to parse port for %s:%s", hostnameAndPort[0], hostnameAndPort[1])
}
grpcPort := int(port) + 10000