Skip to content

[common][dynamicconfig] Move dynamic config to fx Module #6828

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

Merged
merged 3 commits into from
Apr 21, 2025

Conversation

3vilhamster
Copy link
Contributor

@3vilhamster 3vilhamster commented Apr 16, 2025

What changed?
I introduce dynamicconfigfx.Module to inject dynamic config to fx application.

Why?
This is one of the few common dependencies that exist outside of the resource and can be initialized separately.
Also, it ensures a single instance that provides consistent reads of dynamic config if there are multiple services running in one binary.

How did you test it?
Unit tests

Potential risks

Release notes

Documentation Changes

@@ -192,8 +192,8 @@ func getCadencePackageDir() (string, error) {
if err != nil {
panic(err)
}
cadenceIndex := strings.LastIndex(cadencePackageDir, "/cadence/")
cadencePackageDir = cadencePackageDir[:cadenceIndex+len("/cadence/")]
cadenceIndex := strings.LastIndex(cadencePackageDir, "cadence/")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This broke my setup with a folder named /my-cadence/.
I've copied the solution from nosql version

@3vilhamster 3vilhamster enabled auto-merge (squash) April 16, 2025 19:18
p.Logger.Info("initialising NOP dynamic config client")
res = dynamicconfig.NewNopClient()
} else if err != nil {
p.Logger.Error("creating dynamic config client failed, using no-op config client instead", tag.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

Error cases silently switching to no-op config doesn't sound right. I know that's also the current behavior but we should consider failing startup if there's a misconfiguration for dynamicconfigs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, but I'm unsure how safe it is. It's something to consider for v2: a stricter startup to ensure no missing dependencies.

@3vilhamster 3vilhamster merged commit 3c2837b into cadence-workflow:master Apr 21, 2025
23 checks passed
@3vilhamster 3vilhamster deleted the dynamicconfigfx branch April 22, 2025 10:53
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.

2 participants