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

Route::new in upgrade #1891

Merged
merged 5 commits into from Oct 26, 2022
Merged

Route::new in upgrade #1891

merged 5 commits into from Oct 26, 2022

Conversation

82marbag
Copy link
Contributor

Move the creation of Routes in Upgradable to have a cleaner sequence of constraints in ServiceBuilder::build

Signed-off-by: Daniele Ahmed ahmeddan@amazon.de

Motivation and Context

ServiceBuilder::build() is generated and used by customers and has one set of constraints like this one for each operation:

        Op1: aws_smithy_http_server::operation::Upgradable<
            aws_smithy_http_server::proto::rest_json_1::AwsRestJson1,
            crate::operation_shape::CheckHealth,
            Exts1,
            B,
            Pl,
        >,
        Op1::Service: Clone + Send + 'static,
        <Op1::Service as tower::Service<http::Request<B>>>::Future: Send + 'static,
        Op1::Service: tower::Service<http::Request<B>, Error = std::convert::Infallible>,

The last three constraints are specific to how we handle services and should not be surfaced to customers.

Description

Move the creation of Routes in Upgradable and remove the constraints above. Each operation will have only one constraint:

        Op1: aws_smithy_http_server::operation::Upgradable<
            aws_smithy_http_server::proto::rest_json_1::AwsRestJson1,
            crate::operation_shape::CheckHealth,
            Exts1,
            B,
            Pl,
        >,

Testing

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Move the creation of Routes in Upgradable to have a cleaner sequence of
constraints in ServiceBuilder::build

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
@82marbag 82marbag requested a review from a team as a code owner October 21, 2022 15:50
@@ -152,7 +152,7 @@ class ServerServiceGeneratorV2(
private val buildConstraints = operations.zip(builderOps).zip(extensionTypes).map { (first, exts) ->
val (operation, type) = first
// TODO(https://github.com/awslabs/smithy-rs/issues/1713#issue-1365169734): The `Error = Infallible` is an
// excess requirement to stay at parity with existing builder.
// excess requirement to stay at parity with existing builder.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Formatter did this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because Intellij formats TODO lines if they are prefixed with a space, but can remove

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.


// For `Route::new` for the resulting service
<Pl::Layer as Layer<Upgrade<P, Op, Exts, B, Pl::Service>>>::Service: tower::Service<http::Request<B>, Error = std::convert::Infallible>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have tower::Service and Infallible imported here so we don't need tower::Service and std::convert::Infallible.

Same for line 261.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding a type alias to reduce the length of these.

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@82marbag 82marbag enabled auto-merge (squash) October 26, 2022 09:11
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@82marbag 82marbag merged commit 50e8572 into main Oct 26, 2022
@82marbag 82marbag deleted the clean-builder-types branch October 26, 2022 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants