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: support local config file watcher of client and server #1

Merged
merged 34 commits into from
Dec 16, 2023

Conversation

ozline
Copy link
Collaborator

@ozline ozline commented Oct 2, 2023

What type of PR is this?

feat

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

支持将本地文件作为配置并持续监听文件变更以更新配置

(Optional) Which issue(s) this PR fixes:

Fixes cloudwego/kitex#1081

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2023

CLA assistant check
All committers have signed the CLA.

@ozline ozline changed the base branch from main to dev October 2, 2023 07:00
README.md Outdated Show resolved Hide resolved
README_CN.md Outdated Show resolved Hide resolved
client/retry.go Outdated Show resolved Hide resolved
client/retry.go Outdated Show resolved Hide resolved
client/watch.go Outdated Show resolved Hide resolved
client/suite.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
server/watch.go Outdated Show resolved Hide resolved
example/go.mod Outdated Show resolved Hide resolved
example/go.mod Outdated Show resolved Hide resolved
server/suite.go Outdated Show resolved Hide resolved
server/limit.go Outdated Show resolved Hide resolved
utils/filewatcher.go Outdated Show resolved Hide resolved
monitor/monitor.go Outdated Show resolved Hide resolved
monitor/monitor.go Outdated Show resolved Hide resolved
@ozline ozline requested a review from felix021 October 10, 2023 07:03
monitor/test.json Outdated Show resolved Hide resolved
parser/parser.go Outdated Show resolved Hide resolved
@ozline ozline requested a review from felix021 December 2, 2023 16:16
@li-jin-gou li-jin-gou requested review from li-jin-gou and removed request for felix021 December 9, 2023 14:05
@li-jin-gou li-jin-gou self-assigned this Dec 9, 2023
Copy link
Contributor

@li-jin-gou li-jin-gou left a comment

Choose a reason for hiding this comment

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

CI 没过,可以修一下
image

@ozline
Copy link
Collaborator Author

ozline commented Dec 9, 2023

CI 没过,可以修一下 image

刚刚检查了一下,CI 未通过是因为使用到了atomic.Int64来对 callback 做 unique id。这个类型在 1.19 版本引入,先前的sync/atomic中没有这个类型。

查看了一下其他的 config 仓库,我目前移除了 1.17 和 1.18 版本的测试

@ozline ozline changed the title feat: support local config file of client and server feat: support local config file watcher of client and server Dec 9, 2023
Copy link
Member

@XZ0730 XZ0730 left a comment

Choose a reason for hiding this comment

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

  • 感觉日志可以加一些,好像很多地方没打日志
  • 文档中的支持解析的文件类型可以说明一下

README_CN.md Outdated Show resolved Hide resolved
@ozline
Copy link
Collaborator Author

ozline commented Dec 15, 2023

  • 感觉日志可以加一些,好像很多地方没打日志
  • 文档中的支持解析的文件类型可以说明一下

文档已经修正&补充,日志这边我在RegisterCallback添加了额外的 Debug 日志

这边同时修复了一个潜在的导致 panic 的情况:获取配置时 Interface 断言类型错误。尽管在正常操作时不会发生,保险起见还是加上了。

@ozline ozline requested a review from XZ0730 December 15, 2023 18:06
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: li-jin-gou, ozline

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@li-jin-gou li-jin-gou merged commit deb57a5 into kitex-contrib:dev Dec 16, 2023
6 checks passed
li-jin-gou added a commit that referenced this pull request Dec 16, 2023
* feat: support local file config of client and server

* del: .DS_Store

* add: license header

* fix: staticcheck error report

* fix: use NewRetryContainerWithPercentageLimit to create retry container

* docs: correct sentence placement

* fix: use individual module in example folder

* feat: merge ClientWatcher and ServerWatcher into ConfigWatcher

* fix: update error judgment of utils.PathExists()

* docs: update README.md

* chore: move example folder to kitex-contrib/example

* fix: set alias for client/server to avoid same package name

* fix: delete useless log

* fix: add recover for new goroutines to avoid crashing

* add: comments for exported symbols

* del: monitor/key.go

* feat: separating filewatch and configmonitor

* docs: update README.md

* fix: README.md usage import package error

* add: monitor test cases

* test: add entire progress test

* fix: add mutex for start/stop file watching

* fix: staticcheck error report

* fix: multiple clients can listen to the same key without affecting each other

* delete: remove the gomock module and use self-made simple mock instead

* feat: upgrade required module version

* fix: remove redundant golang versions in workflow tests

* add: use example of this lib

* fix: README_CN.md spell error

* chore: README add supported file types

* fix: panic when type assertion fails at runtime

* chore: add log while callback is nil

* fix: README.md lib name error

* chore: add licenses

---------

Co-authored-by: kinggo <lilong.21@bytedance.com>
Ricky-chen1 pushed a commit to Ricky-chen1/config-file that referenced this pull request Feb 12, 2024
…ontrib#1) (kitex-contrib#2)

* feat: support local file config of client and server

* del: .DS_Store

* add: license header

* fix: staticcheck error report

* fix: use NewRetryContainerWithPercentageLimit to create retry container

* docs: correct sentence placement

* fix: use individual module in example folder

* feat: merge ClientWatcher and ServerWatcher into ConfigWatcher

* fix: update error judgment of utils.PathExists()

* docs: update README.md

* chore: move example folder to kitex-contrib/example

* fix: set alias for client/server to avoid same package name

* fix: delete useless log

* fix: add recover for new goroutines to avoid crashing

* add: comments for exported symbols

* del: monitor/key.go

* feat: separating filewatch and configmonitor

* docs: update README.md

* fix: README.md usage import package error

* add: monitor test cases

* test: add entire progress test

* fix: add mutex for start/stop file watching

* fix: staticcheck error report

* fix: multiple clients can listen to the same key without affecting each other

* delete: remove the gomock module and use self-made simple mock instead

* feat: upgrade required module version

* fix: remove redundant golang versions in workflow tests

* add: use example of this lib

* fix: README_CN.md spell error

* chore: README add supported file types

* fix: panic when type assertion fails at runtime

* chore: add log while callback is nil

* fix: README.md lib name error

* chore: add licenses

---------

Co-authored-by: kinggo <lilong.21@bytedance.com>
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.

Proposal: implement server governance configuration based on local file
5 participants