Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc default port init #598

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion clients/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func CreateConfigClient(properties map[string]interface{}) (iClient config_clien
return NewConfigClient(param)
}

//CreateNamingClient use to create a nacos naming client
// CreateNamingClient use to create a nacos naming client
func CreateNamingClient(properties map[string]interface{}) (iClient naming_client.INamingClient, err error) {
param := getConfigParam(properties)
return NewNamingClient(param)
Expand Down Expand Up @@ -104,6 +104,11 @@ func setConfig(param vo.NacosClientParam) (iClient nacos_client.INacosClient, er
}
_ = client.SetServerConfig(nil)
} else {
for i := range param.ServerConfigs {
if param.ServerConfigs[i].GrpcPort == 0 {
param.ServerConfigs[i].GrpcPort = param.ServerConfigs[i].Port + constant.RpcPortOffset
}
}
err = client.SetServerConfig(param.ServerConfigs)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion common/constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const (
KEY_BEAT = "beat"
KEY_DOM = "dom"
DEFAULT_CONTEXT_PATH = "/nacos"
CLIENT_VERSION = "Nacos-Go-Client:v2.2.0"
CLIENT_VERSION = "Nacos-Go-Client:v2.2.1"
REQUEST_DOMAIN_RETRY_TIME = 3
SERVICE_INFO_SPLITER = "@@"
CONFIG_INFO_SPLITER = "@@"
Expand Down Expand Up @@ -98,4 +98,5 @@ const (
HTTPS_SERVER_PORT = 443
GRPC = "grpc"
FAILOVER_FILE_SUFFIX = "_failover"
RpcPortOffset = 1000
)
2 changes: 1 addition & 1 deletion common/remote/rpc/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (c *GrpcClient) getConnectionType() ConnectionType {
}

func (c *GrpcClient) rpcPortOffset() uint64 {
return 1000
return constant.RpcPortOffset
}

func (c *GrpcClient) bindBiRequestStream(streamClient nacos_grpc_service.BiRequestStream_RequestBiStreamClient, grpcConn *GrpcConnection) {
Expand Down