Skip to content
Snippets Groups Projects
Commit 5f0084a4 authored by flycash's avatar flycash
Browse files

Fix review

parent bdd9b71c
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,7 @@ type nacosMetadataReport struct {
}
// StoreProviderMetadata will store the metadata
// metadata including the basic info of the server, provider info, and other user custom info
func (n *nacosMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error {
return n.storeMetadata(vo.ConfigParam{
DataId: providerIdentifier.GetIdentifierKey(),
......@@ -60,6 +61,7 @@ func (n *nacosMetadataReport) StoreProviderMetadata(providerIdentifier *identifi
}
// StoreConsumerMetadata will store the metadata
// metadata including the basic info of the server, consumer info, and other user custom info
func (n *nacosMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error {
return n.storeMetadata(vo.ConfigParam{
DataId: consumerMetadataIdentifier.GetIdentifierKey(),
......@@ -69,6 +71,7 @@ func (n *nacosMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *
}
// SaveServiceMetadata will store the metadata
// metadata including the basic info of the server, service info, and other user custom info
func (n *nacosMetadataReport) SaveServiceMetadata(metadataIdentifier *identifier.ServiceMetadataIdentifier, url common.URL) error {
return n.storeMetadata(vo.ConfigParam{
DataId: metadataIdentifier.GetIdentifierKey(),
......
......@@ -20,9 +20,13 @@ package nacos
import (
"strconv"
"testing"
)
import (
"github.com/stretchr/testify/assert"
)
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
......
......@@ -17,16 +17,13 @@
package nacos
import (
"github.com/apache/dubbo-go/remoting/nacos"
)
import (
"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
)
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/remoting/nacos"
)
// baseRegistry is the parent of both interface-level registry
......
......@@ -70,7 +70,10 @@ func getNacosConfig(url *common.URL) (map[string]interface{}, error) {
if err != nil {
return nil, perrors.WithMessagef(err, "split [%s] ", addr)
}
port, _ := strconv.Atoi(portStr)
port, err := strconv.Atoi(portStr)
if err != nil {
return configMap, perrors.WithMessage(err, "the port string is invalid. "+portStr)
}
serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{
IpAddr: ip,
Port: uint64(port),
......@@ -78,18 +81,21 @@ func getNacosConfig(url *common.URL) (map[string]interface{}, error) {
}
configMap["serverConfigs"] = serverConfigs
var clientConfig nacosConstant.ClientConfig
timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT))
if err != nil {
return nil, err
}
clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000)
clientConfig.ListenInterval = 2 * clientConfig.TimeoutMs
clientConfig.CacheDir = url.GetParam(constant.NACOS_CACHE_DIR_KEY, "")
clientConfig.LogDir = url.GetParam(constant.NACOS_LOG_DIR_KEY, "")
clientConfig.Endpoint = url.GetParam(constant.NACOS_ENDPOINT, "")
clientConfig.NotLoadCacheAtStart = true
configMap["clientConfig"] = clientConfig
timeoutMs := uint64(timeout.Nanoseconds() / constant.MsToNanoRate)
configMap["clientConfig"] = nacosConstant.ClientConfig{
TimeoutMs: timeoutMs,
ListenInterval: 2 * timeoutMs,
CacheDir: url.GetParam(constant.NACOS_CACHE_DIR_KEY, ""),
LogDir: url.GetParam(constant.NACOS_LOG_DIR_KEY, ""),
Endpoint: url.GetParam(constant.NACOS_ENDPOINT, ""),
NotLoadCacheAtStart: true,
}
return configMap, nil
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment