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

Refactor configmapprovider.Provider and Retrieved interfaces #4403

Merged

Conversation

tigrannajaryan
Copy link
Member

This uses a callback instead of a blocking WaitForUpdate function
to notify about config changes.

This simplifies the usage of the Provider, especially when watching
for changes is required.

A follow up PR will add watching capabilities to existing Provider
implementations.

@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #4403 (67c1968) into main (93c9cab) will decrease coverage by 0.01%.
The diff coverage is 78.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4403      +/-   ##
==========================================
- Coverage   90.31%   90.30%   -0.02%     
==========================================
  Files         177      177              
  Lines       10338    10343       +5     
==========================================
+ Hits         9337     9340       +3     
- Misses        779      782       +3     
+ Partials      222      221       -1     
Impacted Files Coverage Δ
service/collector.go 73.37% <0.00%> (ø)
config/configtest/configtest.go 93.61% <50.00%> (-3.05%) ⬇️
config/configmapprovider/merge.go 73.91% <55.55%> (-10.30%) ⬇️
service/config_watcher.go 89.65% <81.25%> (+2.15%) ⬆️
config/configmapprovider/expand.go 71.69% <100.00%> (-4.31%) ⬇️
config/configmapprovider/file.go 100.00% <100.00%> (ø)
config/configmapprovider/inmemory.go 70.00% <100.00%> (ø)
config/configmapprovider/properties.go 89.65% <100.00%> (ø)
config/configmapprovider/simple.go 100.00% <100.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93c9cab...67c1968. Read the comment docs.

service/config_watcher.go Outdated Show resolved Hide resolved
config/configmapprovider/provider.go Show resolved Hide resolved
// TODO: see if this can be eliminated.
type ChangeEvent struct {
// Error is nil if the config is changed and needs to be re-fetched using Get.
// It is set to configsource.ErrSessionClosed if Close was called.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure we need this. When Close is called we can simply just not call the onChange callback. We just need to ensure that we will not call the callback after Close returns.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, see my TODO comment above. Going to look into that separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps we get rid of Error field but keep ChangeEvent for the possibility to extend in the future without breaking the interface.

Copy link
Member

Choose a reason for hiding this comment

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

We still need an "error" for the case when the watcher fails something like an "errorHandler" for the watcher. We either have to funcs "onChange" and "onError" or we have this and if err != nil probably we should close the service? Because I don't know how to recover similar with the Host.ReportError()?

So I would keep for the moment the error.

@tigrannajaryan tigrannajaryan force-pushed the refactor-configprovider branch 2 times, most recently from 3e26c33 to 3d76ad1 Compare November 11, 2021 23:59
This uses a callback instead of a blocking WaitForUpdate function
to notify about config changes.

This simplifies the usage of the Provider, especially when watching
for changes is required.

A follow up PR will add watching capabilities to existing Provider
implementations.
// TODO: see if this can be eliminated.
type ChangeEvent struct {
// Error is nil if the config is changed and needs to be re-fetched using Get.
// It is set to configsource.ErrSessionClosed if Close was called.
Copy link
Member

Choose a reason for hiding this comment

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

We still need an "error" for the case when the watcher fails something like an "errorHandler" for the watcher. We either have to funcs "onChange" and "onError" or we have this and if err != nil probably we should close the service? Because I don't know how to recover similar with the Host.ReportError()?

So I would keep for the moment the error.

@bogdandrutu bogdandrutu merged commit 68602ec into open-telemetry:main Nov 12, 2021
@tigrannajaryan tigrannajaryan deleted the refactor-configprovider branch November 12, 2021 01:35
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.

None yet

2 participants