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

Add MakeService::into_service and MakeService::as_service #492

Merged
merged 8 commits into from
Dec 29, 2020
Merged

Add MakeService::into_service and MakeService::as_service #492

merged 8 commits into from
Dec 29, 2020

Conversation

davidpdrsn
Copy link
Member

Resolves #253

Adds MakeService::into_service and MakeService::as_service which converts MakeServices into Services. into_service consumes self and as_service borrows self mutably.

@davidpdrsn
Copy link
Member Author

One thought I had was that it would be nice if IntoService and AsService were public types so users can name them in type aliases and such. Not sure where to expose them though. tower::make::{IntoService, AsService} doesn't feel right and if we go with tower::make::make_service::{IntoService, AsService} it feels like MakeService should be moved in there as well.

tower/src/make/make_service.rs Outdated Show resolved Hide resolved
tower/src/make/make_service.rs Outdated Show resolved Hide resolved
tower/src/make/make_service.rs Outdated Show resolved Hide resolved
tower/src/make/make_service.rs Outdated Show resolved Hide resolved
davidpdrsn and others added 2 commits December 29, 2020 20:42
@davidpdrsn
Copy link
Member Author

Should we expose them as MakeServiceIntoService and MakeServiceAsService? Both a bit wordy 🤔

@hawkw
Copy link
Member

hawkw commented Dec 29, 2020

Should we expose them as MakeServiceIntoService and MakeServiceAsService? Both a bit wordy thinking

as long as they live in the make module and aren't re-exported at the crate root, I think make::IntoService and make::AsService are better.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

great, this looks good to me! thanks!

Comment on lines 194 to 200
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.make.poll_ready(cx)
}

fn call(&mut self, target: Target) -> Self::Future {
self.make.make_service(target)
}
Copy link
Member

Choose a reason for hiding this comment

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

TIOLI: these could probably be inlined...compiler might be smart enough to figure that out now though...

Copy link
Member Author

Choose a reason for hiding this comment

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

6a753cc 👍

@davidpdrsn
Copy link
Member Author

Should we expose them as MakeServiceIntoService and MakeServiceAsService? Both a bit wordy thinking

as long as they live in the make module and aren't re-exported at the crate root, I think make::IntoService and make::AsService are better.

I was thinking if we wanted to make the types public since the make module is currently private.

@hawkw
Copy link
Member

hawkw commented Dec 29, 2020

I was thinking if we wanted to make the types public since the make module is currently private.

Hmm...let's just make the make module public, then. We should continue re-exporting MakeService from the root of the crate, though, and maybe add #[doc(inline)] on the re-export.

@davidpdrsn
Copy link
Member Author

👌

tower/src/make/mod.rs Outdated Show resolved Hide resolved
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

looks good to me!

@hawkw hawkw merged commit 0100800 into tower-rs:master Dec 29, 2020
@davidpdrsn davidpdrsn deleted the make-service-utils branch December 29, 2020 23:48
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.

MakeConnection: add into_service and as_service
2 participants