-
Notifications
You must be signed in to change notification settings - Fork 155
Expose http transport options #569
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
base: main
Are you sure you want to change the base?
Expose http transport options #569
Conversation
internal/httpclient/client.go
Outdated
| return nil, err | ||
| } | ||
|
|
||
| override := os.Getenv("BENTO_OVERRIDE_DEFAULT_HTTP_TRANSPORT") == "true" |
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.
Why do we not rather extend the public/service/config_tls.go to support these new fields?
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.
Where the implementation is in internal/tls/type.go instead of within the httpClient. That way, any component using our default TLS can leverage the additional fields instead of just relying on those components using httpclient
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.
hmm but most of the fields aren't TLS related? - Isn't the issue more that wherever we use http.DefaultTransport in Bento - we need to provide the option to override - not just in the http_client input, output & http processor?
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.
prolly would want to move it to a separate package for the concern of building http transports - which I think is the point you are making 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.
hmm but most of the fields aren't TLS related? - Isn't the issue more that wherever we use http.DefaultTransport in Bento - we need to provide the option to override - not just in the http_client input, output & http processor?
What I'm trying to say is that if someone wants to use a custom transport and specify their TLS, we handle this seperately instead of together. For example:
tls:
field_a: A
transport:
field_b: Bwhere tls (transport layer security) should be a subset of transport. Like, in the httpclient.ConfigFromParsed we retrieve the TLS config
bento/internal/httpclient/config.go
Lines 155 to 157 in 51abef7
| if conf.TLSConf, conf.TLSEnabled, err = pConf.FieldTLSToggled(hcFieldTLS); err != nil { | |
| return | |
| } |
And then retrieve the transport
bento/internal/httpclient/config.go
Lines 165 to 167 in 51abef7
| if conf.transport, err = pConf.FieldHTTPTransport(hcFieldTransport); err != nil { | |
| return | |
| } |
Where now it's up to the caller to set the transport.TLSClientConfig = tlsConf instead of just returning a single transport with this set.
I suppose it's not a blocker or anything, am more concerned that we're treating two fields that should otherwise be tighly coupled as seperate.
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.
Yeah reading back this convo, I think we aren't really understanding what we are saying - but you are right:
we're treating two fields that should otherwise be tightly coupled as separate
We probably should move the tls & proxyURL stuff into the FieldSpec for a transport that would be cleaner.
Then it's just get the transport and go - no need to clone it to add tls & proxyURL to it...
I just had a thought that to do that you would have to deprecate the http_client.tls then copy it to the http_client.transport - and then is some future time remove the http_client.tls?
d4d5c3a to
69a34fb
Compare
Signed-off-by: Jem Davies <[email protected]>
69a34fb to
dae3a18
Compare
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
774e68c to
de3f636
Compare
Signed-off-by: Jem Davies <[email protected]>
de3f636 to
51abef7
Compare
gregfurman
left a comment
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.
LGTM. I think there's a leftover struct that should be removed. I also think it's woth re-thinking the loose coupling of TLS and Transport but we can explore this in a follow-up.
internal/httptransport/config.go
Outdated
| type CustomTransport struct { | ||
| CustomTransportEnabled bool | ||
| DialContextTimeout time.Duration | ||
| DialContextKeepAlive time.Duration | ||
| ForceAttemptHTTP2 bool | ||
| MaxIdleConns int | ||
| IdleConnTimeout time.Duration | ||
| TlsHandshakeTimeout time.Duration | ||
| ExpectContinueTimeout time.Duration | ||
| } |
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.
Is this used anywhere?
| type CustomTransport struct { | |
| CustomTransportEnabled bool | |
| DialContextTimeout time.Duration | |
| DialContextKeepAlive time.Duration | |
| ForceAttemptHTTP2 bool | |
| MaxIdleConns int | |
| IdleConnTimeout time.Duration | |
| TlsHandshakeTimeout time.Duration | |
| ExpectContinueTimeout time.Duration | |
| } |
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.
taken that out 👍
internal/httpclient/client.go
Outdated
| return nil, err | ||
| } | ||
|
|
||
| override := os.Getenv("BENTO_OVERRIDE_DEFAULT_HTTP_TRANSPORT") == "true" |
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.
hmm but most of the fields aren't TLS related? - Isn't the issue more that wherever we use http.DefaultTransport in Bento - we need to provide the option to override - not just in the http_client input, output & http processor?
What I'm trying to say is that if someone wants to use a custom transport and specify their TLS, we handle this seperately instead of together. For example:
tls:
field_a: A
transport:
field_b: Bwhere tls (transport layer security) should be a subset of transport. Like, in the httpclient.ConfigFromParsed we retrieve the TLS config
bento/internal/httpclient/config.go
Lines 155 to 157 in 51abef7
| if conf.TLSConf, conf.TLSEnabled, err = pConf.FieldTLSToggled(hcFieldTLS); err != nil { | |
| return | |
| } |
And then retrieve the transport
bento/internal/httpclient/config.go
Lines 165 to 167 in 51abef7
| if conf.transport, err = pConf.FieldHTTPTransport(hcFieldTransport); err != nil { | |
| return | |
| } |
Where now it's up to the caller to set the transport.TLSClientConfig = tlsConf instead of just returning a single transport with this set.
I suppose it's not a blocker or anything, am more concerned that we're treating two fields that should otherwise be tighly coupled as seperate.
Signed-off-by: Jem Davies <[email protected]>
Go's DefaultTransport var is currently referenced in:
http_clientinput & outputhttpprocessorschema_registry_decode&schema_registry_encodeprocessorsIt is possible that when using Bento as a library (StreamBuilder for instance), that this DefaultTransport var has been altered, and when a Bento stream that uses the above components is created, it will use the modified DefaultTransport.
This may not be desired.
This PR adds a FieldSpec for a http transport &
func (pConf *ParsedConfig) FieldHTTPTransport()which allows users to create custom http transports from config - based on Go's DefaultTranpsort:And then adds those Config Options to the
http_client,http,schema_registry_decode&schema_registry_encodecomponents.Also as an additional option to deal with potential altered default transports - we have aBENTO_OVERRIDE_DEFAULT_HTTP_TRANSPORTEnv Var that when set to "true" will ensure that the DefaultTransport is not referenced but will create a Transport from the defaults in the config options.TODO:
schema_registry_decodeschema_registry_encodeUpdate last commit removes Env Var and removes references to http.DefaultTransport