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

Add support for call timeouts #70

Merged
merged 7 commits into from
Apr 29, 2019
Merged

Add support for call timeouts #70

merged 7 commits into from
Apr 29, 2019

Conversation

uschi2000
Copy link
Contributor

No description provided.

@uschi2000 uschi2000 requested a review from markelliot April 25, 2019 08:34
@@ -77,7 +77,7 @@ public HttpMethod httpMethod() {
};

/** Returns a new blocking {@link SampleService} implementation whose calls are executed on the given channel. */
public static SampleService blocking(Channel channel, ConjureRuntime runtime) {
public static SampleService blocking(Channel channel, ConjureRuntime runtime, Duration readTimeout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if it'd make more sense for this to be a builder-pattern thing or possibly for the third arg to be some kind of settings object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a TODO, think that'd be a separate PR.

@@ -98,10 +98,12 @@ public String stringToString(String objectId, String header, String body) {
.build();

Call call = channel.createCall(STRING_TO_STRING, request);
ListenableFuture<Response> response = Calls.toFuture(call);
ListenableFuture<String> response = Futures.transform(
Copy link
Contributor

Choose a reason for hiding this comment

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

thoughts on composing the timeouts as a Channel implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm. it wouldn't be so straightforward, because then the async and the blocking client would need different types of channels. (the async client as it stands doesn't do timeouts as callers are in control.) I think I'd revisit that problem when exposing clients that interact with an Observer, because we'd then have to think about how to expose the timeout to those observers.

Copy link
Contributor

Choose a reason for hiding this comment

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

(sorry, missed this comment before the last one I posted)

It seems like async clients should still enforce timeouts on the requests/time-to-response, in which case it'd be the same Channel impl?

@carterkozak
Copy link
Contributor

Is the goal to produce a total request duration timeout from the first bytes sent until the response has been completely read (ignoring streaming binary responses I suppose)? Would you mind documenting that?

There are lots of types of timeouts, and most http libraries don't document what they're actually measuring very well.

@uschi2000
Copy link
Contributor Author

ready

throw new RuntimeException("Failed to deserialize response", e);
}
},
response -> sampleObjectToSampleObjectDeserializer.deserialize(response),
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean the async calls have no timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct. you're handed a Future and are in charge of timing it out yourself via .get(timeout)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can revisit this design if you like, but it seems non-trivial to plumb the timeouts into the underlying http client, in particular for the java one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for instance, the java client doesn't distinguish between read and write timeouts while the okhttp client does

Copy link
Contributor

@markelliot markelliot left a comment

Choose a reason for hiding this comment

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

seems okay -- I think it might be nicer to plumb the timeouts into a channel rather than handling at the service implementation. + one open question on the async impl.

@uschi2000 uschi2000 merged commit 74bdb09 into develop Apr 29, 2019
@uschi2000 uschi2000 deleted the rfink/timeout branch April 29, 2019 08:47
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