Comments (4)
Thanks for reaching out with this issue @moriyoshi. The smithyhttp.Request
's Clone
intentional did not accept a context via its clone method. The intention behind this was that the Request
's Build
method was the entity that attached the context to the underlying http.Request
and returned a constructed http.Request
. Prior to Build
being called the http.Request would not have a Context
associated with it. Build
is intended to be the last action performed on the request before it is used with the HTTP Client.
Could you go into more detail and background about the use case for Clone
to take a context?
from smithy-go.
So what is the use of Clone() in the first place? Is it supposed to be used only in a middleware? I guess not, because it's used in RequestCloner, whose comment says it's intended to use in a retrier. Then should the retrier be able to feed a fresh context on a retry? I would say yes.
from smithy-go.
Thanks for the update. The intention of the middleware is that a context is only associated with an individual request at the last possible moment. Basically right before the request is passed to the HTTP client's Do
method. This is the reason for Build
taking the context but not Clone
. Clone is intended to create a copy of the smithyhttp.Request, and that request has no reference to the Context used by the middleware.
The retryer is a component of the middleware which will create a clone of the request to ensure the request body stream is reset correctly. Also to ensure that any mutations by the signer do not leak between request attempts. It doesn't need to provide a context because the request is context-less until Build
is called when the request is sent to the HTTP client.
The middleware stack it self passes down a context between each layer, and those middleware can mutate the context as needed. Attaching any middleware specific context to the request could cause that context to be invalid by the time the http client's Do method is called. Or each middleware would need to update the request's context. This would create a clone of the request which is not preferred.
from smithy-go.
Thanks for reaching out @moriyoshi. I'm going to close this issue. Please reach out and let us know if you have additional questions, feedback, issues, or feature request.
from smithy-go.
Related Issues (20)
- codegen/runtime: Retries
- codegen/runtime: SRA observability/telemetry
- codegen/runtime: Interceptors
- runtime: sigv4 signer
- runtime: sigv4a signer
- refactor: replace middleware with explicit operation phases
- codegen: remove "V2" suffix from endpoint resolution codegen
- codegen/runtime: @httpChecksum
- publish to maven
- runtime: refactor httpBearerAuth
- codegen: `RuntimeClientPlugin` not having access to a `SymbolProvider` HOT 1
- docs: revamp README and usage guide HOT 1
- Middleware, Transport (and maybe others) broken since aws-sdk-go-v2 release-2023-11-15 HOT 1
- codegen/runtime: operation checksums
- protocol: smithy.protocols#rpcv2Cbor HOT 1
- codegen/runtime: event streams
- Explore ways to reduce size of generated output HOT 3
- codegen: refactor waiters/paginators to be not integrations
- codegen: use DirectedCodegen in client codegen
- rename go-codegen plugin to go-client-codegen
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smithy-go.