Skip to content

Commit 7abb962

Browse files
authored
[chore] Update httpconfig API to not include HTTP prefix (#9453)
Following discussion #9403 (comment)
1 parent 26c157e commit 7abb962

20 files changed

+117
-117
lines changed

.chloggen/httpclientsettings_httpclientconfig-breaking.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ change_type: breaking
77
component: otlphttpexporter
88

99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10-
note: otlphttpexporter.Config embeds the struct confighttp.HTTPClientConfig instead of confighttp.HTTPClientSettings
10+
note: otlphttpexporter.Config embeds the struct confighttp.ClientConfig instead of confighttp.HTTPClientSettings
1111

1212
# One or more tracking issues or pull requests related to the change
1313
issues: [6767]

.chloggen/httpclientsettings_httpclientconfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ change_type: deprecation
77
component: confighttp
88

99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10-
note: Deprecate HTTPClientSettings, use HTTPClientConfig instead
10+
note: Deprecate HTTPClientSettings, use ClientConfig instead
1111

1212
# One or more tracking issues or pull requests related to the change
1313
issues: [6767]

.chloggen/httpserversettings_httpserverconfig-otlpreceiver.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ change_type: breaking
77
component: otlpreceiver
88

99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10-
note: HTTPConfig struct is moving from embedding the deprecated HTTPServerSettings struct to using HTTPServerConfig instead.
10+
note: HTTPConfig struct is moving from embedding the deprecated ServerSettings struct to using HTTPServerConfig instead.
1111

1212
# One or more tracking issues or pull requests related to the change
1313
issues: [6767]

.chloggen/httpserversettings_httpserverconfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ change_type: deprecation
77
component: confighttp
88

99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10-
note: Deprecate HTTPServerSettings, use HTTPServerConfig instead
10+
note: Deprecate HTTPServerSettings, use ServerConfig instead
1111

1212
# One or more tracking issues or pull requests related to the change
1313
issues: [6767]

config/confighttp/compression_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestHTTPClientCompression(t *testing.T) {
9595
req, err := http.NewRequest(http.MethodGet, srv.URL, reqBody)
9696
require.NoError(t, err, "failed to create request to test handler")
9797

98-
clientSettings := HTTPClientConfig{
98+
clientSettings := ClientConfig{
9999
Endpoint: srv.URL,
100100
Compression: tt.encoding,
101101
}

config/confighttp/confighttp.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import (
3030
const headerContentEncoding = "Content-Encoding"
3131

3232
// HTTPClientSettings defines settings for creating an HTTP client.
33-
// Deprecated: [v0.94.0] Use HTTPClientConfig instead
34-
type HTTPClientSettings = HTTPClientConfig
33+
// Deprecated: [v0.94.0] Use ClientConfig instead
34+
type HTTPClientSettings = ClientConfig
3535

36-
// HTTPClientConfig defines settings for creating an HTTP client.
37-
type HTTPClientConfig struct {
36+
// ClientConfig defines settings for creating an HTTP client.
37+
type ClientConfig struct {
3838
// The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
3939
Endpoint string `mapstructure:"endpoint"`
4040

@@ -107,28 +107,28 @@ type HTTPClientConfig struct {
107107
// the default values of 'MaxIdleConns' and 'IdleConnTimeout'.
108108
// Other config options are not added as they are initialized with 'zero value' by GoLang as default.
109109
// We encourage to use this function to create an object of HTTPClientSettings.
110-
// Deprecated: [v0.94.0] Use NewDefaultHTTPClientConfig instead
111-
func NewDefaultHTTPClientSettings() HTTPClientConfig {
112-
return NewDefaultHTTPClientConfig()
110+
// Deprecated: [v0.94.0] Use NewDefaultClientConfig instead
111+
func NewDefaultHTTPClientSettings() ClientConfig {
112+
return NewDefaultClientConfig()
113113
}
114114

115-
// NewDefaultHTTPClientConfig returns HTTPClientConfig type object with
115+
// NewDefaultClientConfig returns ClientConfig type object with
116116
// the default values of 'MaxIdleConns' and 'IdleConnTimeout'.
117117
// Other config options are not added as they are initialized with 'zero value' by GoLang as default.
118-
// We encourage to use this function to create an object of HTTPClientConfig.
119-
func NewDefaultHTTPClientConfig() HTTPClientConfig {
118+
// We encourage to use this function to create an object of ClientConfig.
119+
func NewDefaultClientConfig() ClientConfig {
120120
// The default values are taken from the values of 'DefaultTransport' of 'http' package.
121121
maxIdleConns := 100
122122
idleConnTimeout := 90 * time.Second
123123

124-
return HTTPClientConfig{
124+
return ClientConfig{
125125
MaxIdleConns: &maxIdleConns,
126126
IdleConnTimeout: &idleConnTimeout,
127127
}
128128
}
129129

130130
// ToClient creates an HTTP client.
131-
func (hcs *HTTPClientConfig) ToClient(host component.Host, settings component.TelemetrySettings) (*http.Client, error) {
131+
func (hcs *ClientConfig) ToClient(host component.Host, settings component.TelemetrySettings) (*http.Client, error) {
132132
tlsCfg, err := hcs.TLSSetting.LoadTLSConfig()
133133
if err != nil {
134134
return nil, err
@@ -257,11 +257,11 @@ func (interceptor *headerRoundTripper) RoundTrip(req *http.Request) (*http.Respo
257257
}
258258

259259
// HTTPServerSettings defines settings for creating an HTTP server.
260-
// Deprecated: [v0.94.0] Use HTTPServerConfig instead
261-
type HTTPServerSettings = HTTPServerConfig
260+
// Deprecated: [v0.94.0] Use ServerConfig instead
261+
type HTTPServerSettings = ServerConfig
262262

263-
// HTTPServerConfig defines settings for creating an HTTP server.
264-
type HTTPServerConfig struct {
263+
// ServerConfig defines settings for creating an HTTP server.
264+
type ServerConfig struct {
265265
// Endpoint configures the listening address for the server.
266266
Endpoint string `mapstructure:"endpoint"`
267267

@@ -287,7 +287,7 @@ type HTTPServerConfig struct {
287287
}
288288

289289
// ToListener creates a net.Listener.
290-
func (hss *HTTPServerConfig) ToListener() (net.Listener, error) {
290+
func (hss *ServerConfig) ToListener() (net.Listener, error) {
291291
listener, err := net.Listen("tcp", hss.Endpoint)
292292
if err != nil {
293293
return nil, err
@@ -306,14 +306,14 @@ func (hss *HTTPServerConfig) ToListener() (net.Listener, error) {
306306
}
307307

308308
// toServerOptions has options that change the behavior of the HTTP server
309-
// returned by HTTPServerConfig.ToServer().
309+
// returned by ServerConfig.ToServer().
310310
type toServerOptions struct {
311311
errHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int)
312312
decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error)
313313
}
314314

315315
// ToServerOption is an option to change the behavior of the HTTP server
316-
// returned by HTTPServerConfig.ToServer().
316+
// returned by ServerConfig.ToServer().
317317
type ToServerOption func(opts *toServerOptions)
318318

319319
// WithErrorHandler overrides the HTTP error handler that gets invoked
@@ -336,7 +336,7 @@ func WithDecoder(key string, dec func(body io.ReadCloser) (io.ReadCloser, error)
336336
}
337337

338338
// ToServer creates an http.Server from settings object.
339-
func (hss *HTTPServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) {
339+
func (hss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) {
340340
internal.WarnOnUnspecifiedHost(settings.Logger, hss.Endpoint)
341341

342342
serverOpts := &toServerOptions{}

0 commit comments

Comments
 (0)