Skip to content

Commit

Permalink
grpc default port init (#598)
Browse files Browse the repository at this point in the history
* grpc default port init

* update version
  • Loading branch information
binbin0325 authored Mar 23, 2023
1 parent e25bc91 commit c11cbcc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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

0 comments on commit c11cbcc

Please sign in to comment.