-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
change HTTPClientSettings.ToClient to use component.Host as input #5584
change HTTPClientSettings.ToClient to use component.Host as input #5584
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5584 +/- ##
=======================================
Coverage 91.29% 91.29%
=======================================
Files 191 191
Lines 11291 11294 +3
=======================================
+ Hits 10308 10311 +3
Misses 782 782
Partials 201 201
Continue to review full report at Codecov.
|
config/confighttp/confighttp.go
Outdated
@@ -99,7 +98,7 @@ func NewDefaultHTTPClientSettings() HTTPClientSettings { | |||
} | |||
|
|||
// ToClient creates an HTTP client. | |||
func (hcs *HTTPClientSettings) ToClient(ext map[config.ComponentID]component.Extension, settings component.TelemetrySettings) (*http.Client, error) { | |||
func (hcs *HTTPClientSettings) ToClient(host component.Host, settings component.TelemetrySettings) (*http.Client, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do this in several steps, since this is a breaking change. See example 3 on the contributing guidelines.
Based on these guidelines on this PR we should add a new method ToClientWithHost
where we pass a host instead of an extension map and deprecate the ToClient
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I will change like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do this in several steps, since this is a breaking change. See example 3 on the contributing guidelines.
Based on these guidelines on this PR we should add a new method
ToClientWithHost
where we pass a host instead of an extension map and deprecate theToClient
method.
I added a new function ToClientWithHost
, but I have no idea about how to change ToClient
to call ToClientWithHost
since I can not find a way to create a component.Host
interface from map[config.ComponentID]component.Extension
, do you have any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea about how to change
ToClient
to callToClientWithHost
since I can not find a way to create acomponent.Host
interface frommap[config.ComponentID]component.Extension
, do you have any suggestions?
I don't think you can implement ToClient
by calling ToClientWithHost
. The point of that rule is to avoid duplicating the implementation, so one thing you can do (assuming no linter would complain) is to do it the other way around:
func (hcs *HTTPClientSettings) ToClientWithHost(host component.Host, settings component.TelemetrySettings) (*http.Client, error) {
return hcs.ToClient(host.GetExtensions(), settings)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…s input Signed-off-by: Ziqi Zhao <[email protected]>
Signed-off-by: Ziqi Zhao <[email protected]>
85f29d0
to
8ee357a
Compare
Signed-off-by: Ziqi Zhao <[email protected]>
@@ -183,6 +183,91 @@ func (hcs *HTTPClientSettings) ToClient(ext map[config.ComponentID]component.Ext | |||
}, nil | |||
} | |||
|
|||
// ToClientWithHost creates an HTTP client. | |||
func (hcs *HTTPClientSettings) ToClientWithHost(host component.Host, settings component.TelemetrySettings) (*http.Client, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to deprecate ToClient
in favor of this function (see paragraph about "deprecation notice" here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Co-authored-by: Pablo Baeyens <[email protected]>
Signed-off-by: Ziqi Zhao <[email protected]>
Signed-off-by: Ziqi Zhao [email protected]
Description: <Describe what has changed.
Fix #5061
change httpconfig.HTTPClientSettings.ToClient to use component.Host as input parameters
Link to tracking Issue:
#5061