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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper keep-alive #11

Merged
merged 3 commits into from
Nov 13, 2019
Merged

Proper keep-alive #11

merged 3 commits into from
Nov 13, 2019

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Nov 13, 2019

The previous implementation was wrong due to me not understanding how things actually work 馃榾. This now keeps a connection alive until either waiting for a new HTTP request times out or the connection is closed.

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

Few nits; def looks like an improvement!

examples/server.rs Outdated Show resolved Hide resolved
req = match timeout(timeout_duration, decode(stream)).await {
Ok(Ok(Some(r))) => r,
Ok(Ok(None)) | Err(TimeoutError { .. }) => break, /* EOF or timeout */
Ok(Err(e)) => return Err(e),
Copy link
Member

Choose a reason for hiding this comment

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

Heh, how do we handle the top-level Err case? Are we maybe double wrapping the Result accidentally?

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 outer error is the timeout even though in our case it's not actually an error. The inner error is in fact an actual error in reading the underlying TCP stream. This PR doesn't change how that error gets handled. It currently is propagated to the user so they can handle such errors.

@dignifiedquire
Copy link
Member

dignifiedquire commented Nov 13, 2019

@yoshuawuyts can we merge this? wanted to hack some

@yoshuawuyts
Copy link
Member

@dignifiedquire @rylev feel free to review PRs and merge! -- I think you both get the spirit of this library, so please don't let me be a limiting factor to review and move forward!

@yoshuawuyts yoshuawuyts merged commit 62dec59 into master Nov 13, 2019
@delete-merged-branch delete-merged-branch bot deleted the working-keep-alive branch November 13, 2019 22:44
@rylev rylev mentioned this pull request Nov 14, 2019
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.

None yet

3 participants