Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin0325 committed Jul 21, 2023
1 parent 0d34e0a commit 73f577d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions clients/nacos_client/nacos_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/nacos-group/nacos-sdk-go/v2/common/file"
"github.com/nacos-group/nacos-sdk-go/v2/common/http_agent"
"github.com/nacos-group/nacos-sdk-go/v2/common/logger"
)

type NacosClient struct {
Expand All @@ -36,7 +35,7 @@ type NacosClient struct {
serverConfigs []constant.ServerConfig
}

//SetClientConfig is use to set nacos client Config
// SetClientConfig is use to set nacos client Config
func (client *NacosClient) SetClientConfig(config constant.ClientConfig) (err error) {
if config.TimeoutMs <= 0 {
config.TimeoutMs = 10 * 1000
Expand All @@ -62,15 +61,13 @@ func (client *NacosClient) SetClientConfig(config constant.ClientConfig) (err er
config.LogDir = file.GetCurrentPath() + string(os.PathSeparator) + "log"
}

logger.Infof("logDir:<%s> cacheDir:<%s>", config.LogDir, config.CacheDir)

client.clientConfig = config
client.clientConfigValid = true

return
}

//SetServerConfig is use to set nacos server config
// SetServerConfig is use to set nacos server config
func (client *NacosClient) SetServerConfig(configs []constant.ServerConfig) (err error) {
if len(configs) <= 0 {
//it's may be use endpoint to get nacos server address
Expand All @@ -95,7 +92,7 @@ func (client *NacosClient) SetServerConfig(configs []constant.ServerConfig) (err
return
}

//GetClientConfig use to get client config
// GetClientConfig use to get client config
func (client *NacosClient) GetClientConfig() (config constant.ClientConfig, err error) {
config = client.clientConfig
if !client.clientConfigValid {
Expand All @@ -104,7 +101,7 @@ func (client *NacosClient) GetClientConfig() (config constant.ClientConfig, err
return
}

//GetServerConfig use to get server config
// GetServerConfig use to get server config
func (client *NacosClient) GetServerConfig() (configs []constant.ServerConfig, err error) {
configs = client.serverConfigs
if !client.serverConfigsValid {
Expand All @@ -113,7 +110,7 @@ func (client *NacosClient) GetServerConfig() (configs []constant.ServerConfig, e
return
}

//SetHttpAgent use to set http agent
// SetHttpAgent use to set http agent
func (client *NacosClient) SetHttpAgent(agent http_agent.IHttpAgent) (err error) {
if agent == nil {
err = errors.New("[client.SetHttpAgent] http agent can not be nil")
Expand All @@ -123,7 +120,7 @@ func (client *NacosClient) SetHttpAgent(agent http_agent.IHttpAgent) (err error)
return
}

//GetHttpAgent use to get http agent
// GetHttpAgent use to get http agent
func (client *NacosClient) GetHttpAgent() (agent http_agent.IHttpAgent, err error) {
if client.agent == nil {
err = errors.New("[client.GetHttpAgent] invalid http agent")
Expand Down

0 comments on commit 73f577d

Please sign in to comment.