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

fix #692. cache not working when get err in queryConfig #693

Closed
wants to merge 1 commit into from

Conversation

zxc111
Copy link

@zxc111 zxc111 commented Dec 5, 2023

No description provided.

@CLAassistant
Copy link

CLAassistant commented Dec 5, 2023

CLA assistant check
All committers have signed the CLA.

@@ -228,6 +228,7 @@ func (client *ConfigClient) getConfigInner(param *vo.ConfigParam) (content strin
content = cache.GetFailover(cacheKey, client.configCacheDir)
if len(content) > 0 {
logger.Warnf("%s %s %s is using failover content!", clientConfig.NamespaceId, param.Group, param.DataId)
param.Content = content
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do need to set param

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/nacos-group/nacos-sdk-go/blob/5fedf574d9d87221e51c1102423604a734698f0f/clients/config_client/config_client.go#L180C1-L180C1

func (client *ConfigClient) GetConfig(param vo.ConfigParam) (content string, err error) {
	content, err = client.getConfigInner(&param)
	if err != nil {
		return "", err
	}
	param.UsageType = vo.ResponseType
	if err = filter.GetDefaultConfigFilterChainManager().DoFilters(&param); err != nil {
		return "", err
	}
	content = param.Content
	return content, nil
}

GetConfig call client.getConfigInner(&param). GetConfigInner return content without err when failover or read from cache, and param.Content is set only in the normal process. if don't set param.Content, which content is returned by GetConfig will be empty when failover or cache :

	if response != nil && response.Response != nil && !response.IsSuccess() {
		return response.Content, errors.New(response.GetMessage())
	}
	param.EncryptedDataKey = response.EncryptedDataKey
	param.Content = response.Content
	return response.Content, nil

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/nacos-group/nacos-sdk-go/pull/668,there is a problem with the changes in this, and look at it after repair

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: #697

@binbin0325 binbin0325 closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants