-
Notifications
You must be signed in to change notification settings - Fork 153
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
已完成 |
Quality Gate passedIssues Measures |
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 requestingremoteConfig
while the configuration file might be changing simultaneously.ConfigManager in
pkg/config
Now Supports Viewing Remote ConfigAdded a
ViewConfig
method to theload
interface within the originalConfigManager
(referred to ascm
). This allowscm
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 thatConfigManager
does not have the capability to detect configuration changes, so I did not modify the internal variables ofConfigManager
. Instead,ConfigManager
acts as an intermediary to provide access to ConfigCenter's configuration. This ensures that existing modules relying onConfigManager
or configuration files remain unaffected. Currently, changes to ConfigCenter configurations only impact theHotReload
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 originalpkg/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 aspkg/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?: