-
Notifications
You must be signed in to change notification settings - Fork 221
Add http-1x codegen support for server SDK generation #4376
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: feature/http-1.x
Are you sure you want to change the base?
Conversation
This commit introduces comprehensive http-1x support to the server code generator, enabling generation of server SDKs that work with either [email protected] or [email protected] based on the `http-1x` codegen flag. ## Key Changes ### New Infrastructure - **HttpDependencies.kt**: New data class that ensures cohesive HTTP dependency selection, preventing accidental mixing of HTTP 0.x and 1.x versions. Provides helper methods for accessing HTTP types (Request, Response, HeaderMap, etc.) - **MultiVersionTestFailure.kt**: Test infrastructure for tracking failures by HTTP version, enabling tests to run against both http@0 and http@1 ### ServerRustSettings Updates - Add `http1x` boolean flag to control HTTP version selection - Add helper methods `isHttp0()` and `isHttp1()` for version checks ### ServerCodegenContext Updates - Add `httpDependencies: HttpDependencies` property to provide version-appropriate HTTP dependencies throughout code generation ### ServerRequiredCustomizations - Update to create and manage HttpDependencies based on http-1x setting - For http@0: use aws-smithy-legacy-http-server - For http@1: use [email protected] ### Protocol & Test Generator Updates - **ServerProtocolTestGenerator**: Support running protocol tests against both HTTP versions, with configurable test runtime mode (AS_CONFIGURED, BOTH, etc.) - **ServerHttpBoundProtocolGenerator**: Use HttpDependencies for all HTTP type references instead of hardcoded dependencies ### Generator Updates Updated generators to use HttpDependencies for type resolution: - ServerRootGenerator: Use httpDeps for dependency selection - ServerServiceGenerator: Pass HttpDependencies to child generators - ServerHttpSensitivityGenerator: Use httpDeps for HTTP types - ServerOperationGenerator, ServerBuilderGenerator: Use contextual HTTP deps ### Test Infrastructure - **ServerCodegenIntegrationTest**: Add multi-version test support with ability to run tests against both HTTP versions - **Http1xDependencyTest**: New test validating correct dependency selection based on http-1x flag - Update existing tests to work with multi-version infrastructure ### Core Changes - HttpBindingGenerator: Accept HttpDependencies parameter for version-appropriate type generation - EventStream generators: Use contextual HTTP dependencies - SmithyTypesPubUseExtra: Conditional imports based on HTTP version ## Testing All protocol tests can now run against both HTTP versions to ensure compatibility. Tests track failures by HTTP version for easier debugging. Related to http-1x migration effort and aws-smithy-http-legacy-server support.
.changelog/1762113734.md
Outdated
| --- | ||
| Add http-1x codegen support for server SDK generation | ||
|
|
||
| Enables generation of server SDKs compatible with either [email protected]/[email protected] or [email protected]/[email protected] based on the http-1x codegen flag. |
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.
need more detail in the changelog message--e.g. changelog needs to say what the actual flag is, how to enable it etc.
| val httpDeps = HttpDependencies.create(settings.codegenConfig.http1x, rustSymbolProviderConfig.runtimeConfig) | ||
| EventStreamSymbolProvider(rustSymbolProviderConfig.runtimeConfig, it, CodegenTarget.SERVER, httpDeps.smithyHttp) |
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 would recommend that we actually make RuntimeConfig "do the right thing". Or make it so that you MUST pass an http version setting when getting the dependencies that depend on it.
You could incorporate the http1x setting into RuntimeConfig potentially, then make things like smithyHttp http version aware?
I'm worried that the way the code works right now will be somewhat confusing for folks to deal with and create these really confusing compilation errors.
| ) | ||
| } | ||
| if (hasStreamingOperations(model, codegenContext.serviceShape)) { | ||
| println("[ServerRequiredCustomizations.pubUseSmithyPrimitivesHttp0x] Adding rt-tokio with http-body-0-4-x") |
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.
did you want to leave these printlns?
| class StatusCodeSensitivity(private val sensitive: Boolean, private val smithyHttpServer: RuntimeType) { | ||
| private val codegenScope = | ||
| arrayOf( | ||
| "SmithyHttpServer" to ServerCargoDependency.smithyHttpServer(runtimeConfig).toType(), |
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 think we should probably have ServerCargoDependency.smithyHttpServerAuto that automatically gives you the right one. I think the http version would actually fit pretty naturally into RuntimeConfig as an optional parameter.
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.
But if you just want to ship things like it is, I get that. I'm just kinda worried about the long term fallout of having it be non-centralized especially as we eventually try to get rid of the old codegen settings.
This commit introduces comprehensive http-1x support to the server code generator,
enabling generation of server SDKs that work with either [email protected] or [email protected]
based on the
http-1xcodegen flag.Key Changes
New Infrastructure
HttpDependencies.kt: New data class that ensures cohesive HTTP dependency
selection, preventing accidental mixing of HTTP 0.x and 1.x versions. Provides
helper methods for accessing HTTP types (Request, Response, HeaderMap, etc.)
MultiVersionTestFailure.kt: Test infrastructure for tracking failures by
HTTP version, enabling tests to run against both http@0 and http@1
ServerCodegenConfig Updates
http1xboolean field to control HTTP version selection (config key:http-1x)false([email protected])ServerCodegenContext Updates
isHttp1()method to check if http-1x is enabledhttpDependencies()method to provide version-appropriate HTTP dependenciesthroughout code generation
ServerRequiredCustomizations
Protocol & Test Generator Updates
HTTP versions, with configurable test runtime mode (AS_CONFIGURED, BOTH, etc.)
references instead of hardcoded dependencies
Generator Updates
Updated generators to use HttpDependencies for type resolution:
Test Infrastructure
ability to run tests against both HTTP versions
based on http-1x flag
Core Changes
type generation
Testing
All protocol tests can now run against both HTTP versions to ensure compatibility.
Tests track failures by HTTP version for easier debugging.
Relates to #3362