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

Regression in 0.57 where default generic for service struct was removed #3177

Closed
david-perez opened this issue Nov 10, 2023 · 0 comments · Fixed by #3197
Closed

Regression in 0.57 where default generic for service struct was removed #3177

david-perez opened this issue Nov 10, 2023 · 0 comments · Fixed by #3197
Labels
bug Something isn't working server Rust server SDK

Comments

@david-perez
Copy link
Contributor

david-perez commented Nov 10, 2023

Prior to 0.57, one could build and return a service from a function like this:

pub fn build_service() -> PokemonService {
    let service = PokemonService::builder_without_plugins()
        .operation(operation_handler)
        .build()
        .expect("unable to build service");

    service.boxed()
}

This is because we had a default generic on the service struct. But since #3095, this no longer compiles, because we accidentally removed that default generic:

image

So even in the most common use case where the user doesn't want to be generic over the body type and was satisfied with aws_smithy_http_server::body::Body, they now need to write this function as:

pub fn build_service() -> PokemonService<
    aws_smithy_http_server::routing::RoutingService<
      aws_smithy_http_server::protocol::rest::router::RestRouter<
        aws_smithy_http_server::routing::Route<aws_smithy_http_server::body::Body>,
      >,
      aws_smithy_http_server::protocol::rest_json_1::RestJson1,
    >,
> {
    let service = PokemonService::builder_without_plugins()
        .operation(operation_handler)
        .build()
        .expect("unable to build service");

    service.boxed()
}

This is a regression we didn't catch because we don't have any tests in our suite that initialize the service within a function. We should keep providing a default for the S generic for the most common use case.

@david-perez david-perez added bug Something isn't working server Rust server SDK labels Nov 10, 2023
david-perez added a commit that referenced this issue Nov 14, 2023
This was accidentally removed in #3095.

Fixes #3177.
david-perez added a commit that referenced this issue Nov 14, 2023
This was accidentally removed in #3095.

Fixes #3177.
david-perez added a commit that referenced this issue Nov 14, 2023
This was accidentally removed in #3095.

Fixes #3177.
david-perez added a commit that referenced this issue Nov 14, 2023
This was accidentally removed in #3095.

Fixes #3177.
github-merge-queue bot pushed a commit that referenced this issue Nov 14, 2023
This was accidentally removed in #3095.

Fixes #3177.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Rust server SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant