Skip to content

Timeout improvements #26

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

Closed
wants to merge 13 commits into from
Closed

Timeout improvements #26

wants to merge 13 commits into from

Conversation

danieleades
Copy link

@danieleades danieleades commented Aug 14, 2019

Description

By wrapping the return type of the error returned by the timeout method, the restrictions on the type of error are removed, and a consumer can differentiate whether the timeout deadline was hit, or whether the inner future errored. This is a breaking change.

Motivation and Context

In its present state, this method can only be used with error types that implement Fromio::Error which is restrictive. additionally, if the error type already has a Fromio::Error implementation, it becomes unergonomic to distinguish between timeouts and other types of error

How Has This Been Tested?

Yep (see completed checks below)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@danieleades
Copy link
Author

build issues appear to be related to http-rs/tide#305

@danieleades
Copy link
Author

can't for the life of me figure out why this isn't building. It's complaining that the trait bound 'ext::TimeoutStream<S>: futures_core::stream::Stream' is not satisfied

   --> /home/dan/.cargo/registry/src/git.cakeli.workers.dev-1ecc6299db9ec823/futures-timer-0.2.1/src/ext.rs:170:9
    |
170 | impl<S> TryStream for TimeoutStream<S>
    |         ^^^^^^^^^ the trait `futures_core::stream::Stream` is not implemented for `ext::TimeoutStream<S>`                                                                                                   
    |
    = note: required because of the requirements on the impl of `futures_core::stream::private_try_stream::Sealed` for `ext::TimeoutStream<S>`                                                                    

It looks like the blanket implementation of TryStream is failing, but I can't see why it should.

two things-

  • It only fails when running cargo test, not when running cargo build
  • the master branch is also failing in the exact same way

@taiki-e
Copy link
Contributor

taiki-e commented Aug 23, 2019

@danieleades Build failure on the master branch was fixed in #27.

@danieleades
Copy link
Author

@danieleades Build failure on the master branch was fixed in #27.

aha! thanks for this. that should do it

@danieleades danieleades marked this pull request as ready for review August 24, 2019 03:43
@taiki-e taiki-e mentioned this pull request Aug 28, 2019
8 tasks
@yoshuawuyts
Copy link
Contributor

@danieleades thanks heaps for filing this! -- I agree with the reasoning you've outlined here, and in fact we came to a similar conclusion when designing the APIs in async-std.

Something I'm moderately concerned about is how it would work when integrating with some of the codebases we've built on top of this. cc/ @stjepang I feel you might have a good sense of whether these changes would be compatible with async-std (I assume so, but want to make sure) -- could you perhaps take a look?

@ghost
Copy link

ghost commented Sep 2, 2019

I like this set of changes! :) I think my only comment is to rename the Waited struct to TimeoutError, like @yoshuawuyts also suggested.

@danieleades
Copy link
Author

any progress on this @yoshuawuyts ?

This was referenced Oct 9, 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.

3 participants