Skip to content

add deadlines #57

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

Merged
merged 5 commits into from
Jul 3, 2019
Merged

add deadlines #57

merged 5 commits into from
Jul 3, 2019

Conversation

artemredkin
Copy link
Collaborator

Add deadline argument to API methods

Copy link
Contributor

@weissi weissi 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 but small nitpick

@@ -58,16 +58,16 @@ public class HTTPClient {
}
}

public func get(url: String, timeout: Timeout? = nil) -> EventLoopFuture<Response> {
public func get(url: String, timeout: Timeout? = nil, deadline: NIODeadline? = nil) -> EventLoopFuture<Response> {
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be either a dealine or a timeout I think, doesn't make sense to specify both.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking about it, but it will basically double the number of methods... Do you think it's ok? Also, we have to deal with both timeout and deadline anyway, since client can have configuration timeouts for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, better 2x methods that make sense rather then 1x methods that don't make sense.
If you really hate it, make an enum that is either timeout or deadline or just get rid of the timeouts :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@tanner0101 / @ianpartridge what are your thoughts here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be tempted to only do deadlines. You can make a timeout from a deadline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, this is not a good idea :D, timeout is composite, consisting of read and connect timeouts, so it's not that strait-forward to convert deadline to timeout...

Copy link
Contributor

Choose a reason for hiding this comment

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

@artemredkin could you expand here? The user only cares that the get request is done at a certain point in time, right? They don't care how much of that time is spent in connect or read. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, I would put the read and connect timeouts on the overall client configuration, then put a deadline on the individual requests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lets try just deadlines, anything else worth fixing in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

@artemredkin I'd say let's get it in

@artemredkin artemredkin added this to the 1.0.0 milestone Jul 2, 2019
@artemredkin artemredkin added the kind/enhancement Improvements to existing feature. label Jul 2, 2019
Copy link
Contributor

@weissi weissi left a comment

Choose a reason for hiding this comment

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

thanks, that looks good to me now

@artemredkin artemredkin merged commit 9b1e9d3 into master Jul 3, 2019
@artemredkin artemredkin deleted the deadlines branch July 3, 2019 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements to existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants