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

feat: added support for configcenter listening and logger hot-reloading #647

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

mutezebra
Copy link
Contributor

What this PR does:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

The following is the content of this PR

ConfigCenter Listening

Implemented the ConfigCenter's ability to listen for configuration file changes and configured the onChange function to trigger hot updates. This process ensures concurrency safety, as consistency must be maintained when requesting remoteConfig while the configuration file might be changing simultaneously.

ConfigManager in pkg/config Now Supports Viewing Remote Config

Added a ViewConfig method to the load interface within the original ConfigManager (referred to as cm). This allows cm to access the remote configuration from ConfigCenter. Additionally, a function with the same name was added to expose the latest ConfigCenter configuration externally.

HotReload

Defined the foundational structure for HotReload and implemented concurrency-safe hot updates for the logger module.

This process is achieved through a scheduled task that periodically requests the latest ConfigCenter configuration from cm. It then checks if the configuration file has been updated and triggers a hot update if changes are detected. It is important to note that ConfigManager does not have the capability to detect configuration changes, so I did not modify the internal variables of ConfigManager. Instead, ConfigManager acts as an intermediary to provide access to ConfigCenter's configuration. This ensures that existing modules relying on ConfigManager or configuration files remain unaffected. Currently, changes to ConfigCenter configurations only impact the HotReload module.

Testing

Wrote comprehensive unit tests to ensure the correctness of the functionality. During local testing of the compiled pixiu, I encountered a dependency issue: the original pkg/config used "github.com/ghodss/yaml", which is based on "gopkg.in/yaml.v2". This implementation failed to parse certain parameters in YAML files (e.g., a list with mixed types, such as pkg/model/bootstrap.go Bootstrap.Nacos.ServerConfigs). Additionally, the library is no longer actively maintained. After researching, I found that "gopkg.in/yaml.v3" resolves this issue and is compatible with our project's usage of related functions. As a result, I updated all relevant dependencies.

Document

Added config_with_nacos.yaml to the configs directory to provide a template for using ConfigCenter. Previously, the functionality existed but was not documented.

Does this PR introduce a user-facing change?:

NONE

Copy link
Contributor

@No-SilverBullet No-SilverBullet left a comment

Choose a reason for hiding this comment

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

1.import格式需要使用formatter格式化,参考imports-formatter -path . -module github.com/apache/dubbo-go-samples -bl false

@mutezebra
Copy link
Contributor Author

1.import格式需要使用formatter格式化,参考imports-formatter -path . -module github.com/apache/dubbo-go-samples -bl false

已完成

Copy link

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