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

Adding Watchable and Closeable to ParserProvider interface #2954

Merged

Conversation

pjanotti
Copy link
Contributor

Add interfaces to ParserProvider so it can handle configurations that trigger reload. Intended to be used with config sources.

Missing: a test to cover the update configuration on appplication_test.go

@pjanotti pjanotti requested a review from a team April 16, 2021 22:58
go func() {
err := watchable.WatchForUpdate()
switch {
case errors.Is(err, configsource.ErrSessionClosed):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If wanted we could add specific errors directly on parserprovider package so no import of configsource.

Copy link
Member

Choose a reason for hiding this comment

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

Please add a TODO

"context"

"go.opentelemetry.io/collector/config"
)

// ParserProvider is an interface that helps providing configuration's parser.
// Implementations may load the parser from a file, a database or any other source.
type ParserProvider interface {
// Get returns the config.Parser if succeed or error otherwise.
Get() (*config.Parser, error)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it will be good to pass the logger and ApplicationStartInfo.

Copy link
Member

Choose a reason for hiding this comment

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

No need in the first version.

@codecov
Copy link

codecov bot commented Apr 16, 2021

Codecov Report

Merging #2954 (7020835) into main (2b33043) will decrease coverage by 0.09%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2954      +/-   ##
==========================================
- Coverage   91.68%   91.58%   -0.10%     
==========================================
  Files         312      312              
  Lines       15341    15357      +16     
==========================================
  Hits        14065    14065              
- Misses        870      883      +13     
- Partials      406      409       +3     
Impacted Files Coverage Δ
service/application.go 69.28% <0.00%> (-8.95%) ⬇️

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 2b33043...7020835. Read the comment docs.

service/application.go Outdated Show resolved Hide resolved
go func() {
err := watchable.WatchForUpdate()
switch {
case errors.Is(err, configsource.ErrSessionClosed):
Copy link
Member

Choose a reason for hiding this comment

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

Please add a TODO

service/application.go Outdated Show resolved Hide resolved
"context"

"go.opentelemetry.io/collector/config"
)

// ParserProvider is an interface that helps providing configuration's parser.
// Implementations may load the parser from a file, a database or any other source.
type ParserProvider interface {
// Get returns the config.Parser if succeed or error otherwise.
Get() (*config.Parser, error)
Copy link
Member

Choose a reason for hiding this comment

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

No need in the first version.

@bogdandrutu bogdandrutu merged commit 90b2dec into open-telemetry:main Apr 17, 2021
@pjanotti pjanotti deleted the make-provider-watchable-closeable branch April 17, 2021 00:05
// If provider is watchable start a goroutine watching for updates.
if watchable, ok := app.parserProvider.(parserprovider.Watchable); ok {
go func() {
err := watchable.WatchForUpdate()
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we expected this method to block until an error occurs? If that is the case I think this should be explicit in the Watchable interface.

@jcchavezs
Copy link
Contributor

Just to get this clear. Whenever we reload the service because of a config change we will shutdown all components and launch a new instance which will then start receiving ingress, isn't?

hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
* install goimports w/ tools

* lint fixes
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.

3 participants