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

aws.BuildableHTTPClient with options method pattern is awkward to use. #730

Closed
jasdel opened this issue Sep 16, 2020 · 1 comment · Fixed by #898
Closed

aws.BuildableHTTPClient with options method pattern is awkward to use. #730

jasdel opened this issue Sep 16, 2020 · 1 comment · Fixed by #898
Labels
feature-request A feature should be added or improved. usability

Comments

@jasdel
Copy link
Contributor

jasdel commented Sep 16, 2020

Using the client configuration options with the BuildableHTTPClient is fairly awkward to use. If multiple options are desired like Transport and Dialer the return value of the option method must be recasted back to the BuildableHTTPClient before the new option can be applied.

e.g. in the updated EC2 IMDS client custom configuration of the Client's timeouts requires this cast.

client := aws.NewBuildableHTTPClient()

// Use a custom Dial timeout for the EC2 Metadata service to account
// for the possibility the application might not be running in an
// environment with the service present. The client should fail fast in
// this case.
client = c.WithDialerOptions(func(d *net.Dialer) {
	d.Timeout = defaultDialerTimeout
})

// Cast back to the BuildableHTTPClient to add additional options.
c = client.(*aws.BuildableHTTPClient)

// Use a custom Transport timeout for the EC2 Metadata service to
// account for the possibility that the application might be running in
// a container, and EC2Metadata service drops the connection after a
// single IP Hop. The client should fail fast in this case.
client = c.WithTransportOptions(func(tr *http.Transport) {
	tr.ResponseHeaderTimeout = defaultResponseHeaderTimeout
})
@jasdel jasdel added the feature-request A feature should be added or improved. label Sep 16, 2020
@jasdel jasdel changed the title aws.BuildableHTTPClient builder pattern is awkward to use. aws.BuildableHTTPClient with options method pattern is awkward to use. Sep 16, 2020
jasdel added a commit that referenced this issue Nov 12, 2020
…ckage

Moves the BuildableHTTPClient from the SDK's `aws` package to the
`aws/transport/http` package as `BuildableClient` to with other HTTP specific
utilities.

Updates the BuildableClient's method return type to be the
BuildableClient type to make chaining `With` statements more natural.

Fixes #730
jasdel added a commit that referenced this issue Nov 13, 2020
Moves the BuildableHTTPClient from the SDK's aws package to the aws/transport/http package as BuildableClient to with other HTTP specific utilities.

Updates the BuildableClient's method return type to be the BuildableClient type to make chaining With statements more natural.

Fixes #730
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. usability
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant