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(config): Implement notification system for Config #517

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

EduardGomezEscandell
Copy link
Contributor

@EduardGomezEscandell EduardGomezEscandell commented Jan 29, 2024

I want cloud-init & landscape to be pinged by the config every time something changes. However, I don't want these two utilities to be dependencies of config. If anything, I want the dependency the other way around! Cloud-init and Landscape should import config.

So I must somehow call these utilities from the config without importing them. My solution: callbacks. Any utility can now wait on config changes by using:

conf.Notify(func() {
    fmt.Println("Hello, world")
})

and this function will be called every time the config is changed (via GUI, registry, or any future methods).

This is used in Landscape #515 and Cloud-init #506.

I want cloud-init & landscape to depend on the Conf, and not vice-versa. So I must
somehow call these utilities from the config. My solution: callbacks.
@EduardGomezEscandell EduardGomezEscandell self-assigned this Jan 29, 2024
@EduardGomezEscandell EduardGomezEscandell marked this pull request as ready for review January 29, 2024 16:41
@EduardGomezEscandell EduardGomezEscandell requested a review from a team as a code owner January 29, 2024 16:41
Copy link
Contributor

@CarlosNihelton CarlosNihelton left a comment

Choose a reason for hiding this comment

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

No blockers, just some design considerations to check.

windows-agent/internal/config/config.go Outdated Show resolved Hide resolved
windows-agent/internal/config/config.go Outdated Show resolved Hide resolved
windows-agent/internal/config/config.go Outdated Show resolved Hide resolved
windows-agent/internal/config/config.go Outdated Show resolved Hide resolved
windows-agent/internal/config/config_test.go Show resolved Hide resolved
EduardGomezEscandell and others added 2 commits January 31, 2024 10:16
Renamed notifiers to observers, and extracted the notification workflow
into its own separate function.
Copy link

codecov bot commented Jan 31, 2024

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Contributor

@CarlosNihelton CarlosNihelton left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏽

@EduardGomezEscandell EduardGomezEscandell merged commit 63ead74 into main Feb 1, 2024
33 of 34 checks passed
@EduardGomezEscandell EduardGomezEscandell deleted the config-notify branch February 1, 2024 08:45
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