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(transport): Add server graceful shutdown #169

Merged
merged 8 commits into from
Dec 11, 2019

Conversation

xd009642
Copy link
Contributor

@xd009642 xd009642 commented Dec 9, 2019

Some error messages, one about hyper::server::Builder not existing and another about lack of clone on futures. Just putting this up as an initial WIP to make sure I'm on the right track :)

Motivation

Recommended good practice for gRPC so should be exposed

Solution

Expose it via builder pattern

Some error messages, one about hyper::server::Builder not existing and another about lack of clone on futures. Just putting this up as an initial WIP to make sure I'm on the right track :)
@@ -110,6 +111,14 @@ impl Server {
}
}

/// Set the graceful shutdown thing
pub fn graceful_shutdown(self, shutdown: Box<dyn Future<Output=()>>) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably make this impl Future<Output = ()> and then box it internally.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@LucioFranco
Copy link
Member

hmm looks like there are some compile errors?

Co-Authored-By: Lucio Franco <luciofranco14@gmail.com>
@xd009642
Copy link
Contributor Author

xd009642 commented Dec 9, 2019

Yeah hyper::server::builder isn't found in hyper::server but that's not something I changed...

@xd009642
Copy link
Contributor Author

xd009642 commented Dec 9, 2019

Oh wait I did change something! Sorting it now

Issues wth sizes I can't know the size of so moved to try something else
Going back to the old way but now with pins and boxes. Issues with Option requiring Clone and Unpin for dyn Future
@xd009642
Copy link
Contributor Author

@LucioFranco did you have a chance to look at my type based woes?

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@LucioFranco
Copy link
Member

Looks like there are a couple of CI failures, mind fixing them, then we can merge this.

@xd009642
Copy link
Contributor Author

Yeah but I'm not sure quite how, my attempt to make serve_common to avoid repeating code leads to type inside `async` object must be known in this context because I think the acceptor type isn't known from the calling context. I could just duplicate the code across the two functions but I was hoping to do something cleaner than that

Can't get past generic type restricts on async functions so just went for the code duplication approach in the interest of getting something working
@LucioFranco LucioFranco changed the title WIP: graceful shutdown feat(transport): Add server graceful shutdown Dec 11, 2019
@LucioFranco LucioFranco merged commit 393a57e into hyperium:master Dec 11, 2019
rabbitinspace pushed a commit to satelit-project/tonic that referenced this pull request Jan 1, 2020
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.

2 participants