-
Notifications
You must be signed in to change notification settings - Fork 172
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
Allow awaiting on server handles #550
Conversation
stop_sender: mpsc::Sender<()>, | ||
stop_handle: Option<tokio::task::JoinHandle<()>>, | ||
pub(crate) handle: Option<tokio::task::JoinHandle<()>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is pub(crate)
only needed for tests or why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used for tests
server_handle.with_timeout(TIMEOUT).await.unwrap_err(); | ||
|
||
let (_addr, server_handle) = server().await; | ||
server_handle.handle.as_ref().unwrap().abort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, you did this instead of stop
because it moves the JoinHandle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop is a little bit different, here we want to emulate the actual server behavior -- if a task is cancelled or panics, the future handle resolves too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, I like it
some minor questions to answered :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work!
HttpStopHandle
andWsStopHandle
toHttpServerHandle
andWsServerHandle
respectivelyFuture
for both allowing to doto run the server forever.
The interfaces for HTTP and WS are slightly different in the sense that the latter handle can be cloned. This can be easily implemented via channels for HTTP but that's a subject for different PR and was not introduced here.
Resolves #547