mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring
This commit is contained in:
parent
e9eddfb8a2
commit
9d402ebe9f
|
@ -109,15 +109,19 @@ func WithCachedGrpcClient(fn func(*grpc.ClientConn) error, address string, opts
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseServerToGrpcAddress(server string) (serverGrpcAddress string, err error) {
|
func ParseServerToGrpcAddress(server string) (serverGrpcAddress string, err error) {
|
||||||
|
return ParseServerAddress(server, 10000)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseServerAddress(server string, deltaPort int) (newServerAddress string, err error) {
|
||||||
|
|
||||||
host, port, parseErr := hostAndPort(server)
|
host, port, parseErr := hostAndPort(server)
|
||||||
if parseErr != nil {
|
if parseErr != nil {
|
||||||
return "", fmt.Errorf("server port parse error: %v", parseErr)
|
return "", fmt.Errorf("server port parse error: %v", parseErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
grpcPort := int(port) + 10000
|
newPort := int(port) + deltaPort
|
||||||
|
|
||||||
return fmt.Sprintf("%s:%d", host, grpcPort), nil
|
return fmt.Sprintf("%s:%d", host, newPort), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostAndPort(address string) (host string, port uint64, err error) {
|
func hostAndPort(address string) (host string, port uint64, err error) {
|
||||||
|
|
Loading…
Reference in a new issue