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

feat(server): Remove into_service api #1996

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tottoto
Copy link
Collaborator

@tottoto tottoto commented Oct 12, 2024

Removes into_service() api. This is the same as the one composed of the layers and the Routes.

@@ -897,6 +897,7 @@ impl<L> Router<L> {
}

/// Create a tower service out of a router.
#[deprecated(since = "0.12.4", note = "compose the layers and the `Routes`")]
Copy link
Contributor

Choose a reason for hiding this comment

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

So how would you spell this in 0.13?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What is the purpose? Should this api be kept in 0.13?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm asking what the replacement looks like, in order to better understand how much boilerplate this call is hiding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. In the case where this API is used, users can build Routes in advance, so they can set some layers to the Routes with some means, for example tower's ServiceBuilder.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand -- do you have a code snippet showing what that would look like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The following is an example if using tower's ServiceBuilder:

let routes = Routes::new(service()).prepare();

let service = tower::ServiceBuilder::new()
    .layer(layer())
    .service(routes);

Copy link
Collaborator

@tobz tobz left a comment

Choose a reason for hiding this comment

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

At a high level, I wonder if it makes more sense to think about deprecating either Routes or Server entirely.

It seems like they both do nearly the same thing, except for Server allowing for actually running (server) the server.. so it feels weird to incrementally deprecate a method here and there when it's (IMO) a bigger problem that they two types both exist with such heavy overlap.

@tottoto
Copy link
Collaborator Author

tottoto commented Oct 22, 2024

At a high level, I wonder if it makes more sense to think about deprecating either Routes or Server entirely.

I don't think so. Routes is responsible for configuring the service router, while Server builds a server on top of Routes, so their roles are different. It would make sense if Server could handle other Routes equivalents and allow us to change the service router to be used, but that would be a relatively big change.

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.

3 participants