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 client and server support for gRPC deadlines #1462

Merged
merged 13 commits into from
Apr 14, 2021

Conversation

bondolo
Copy link
Contributor

@bondolo bondolo commented Mar 27, 2021

Motivation:
Some gRPC usages require completion of calls within specified time limits. The gRPC protocol provides capability for specifying timeout (aka deadline) for completion of calls.

Modifications:
Features are added to support specification of call timeouts.

Result:
ServiceTalk gRPC API now supports gRPC timeout functionality.

@bondolo bondolo self-assigned this Mar 27, 2021
@bondolo bondolo marked this pull request as draft March 27, 2021 00:29
@bondolo bondolo marked this pull request as ready for review March 31, 2021 19:58
@bondolo bondolo force-pushed the deadline-grpc branch 2 times, most recently from 549a5a5 to 520b63f Compare April 2, 2021 00:29
@idelpivnitskiy
Copy link
Member

The overall approach looks great! My comments mostly about details

Copy link
Contributor Author

@bondolo bondolo left a comment

Choose a reason for hiding this comment

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

Thank you for the review feedback. I haven't resolved all of the issues yet so there will be additional changesets eventually.

@bondolo bondolo force-pushed the deadline-grpc branch 2 times, most recently from 3e16055 to 34b4cb2 Compare April 6, 2021 23:09
@bondolo bondolo requested a review from idelpivnitskiy April 14, 2021 00:15
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Looks great! Couple more things to discuss and ready to be shipped

// demonstration purposes.
CountDownLatch responseProcessedLatch = new CountDownLatch(2);

// Make a request using default timeout (this will succeed)
Copy link
Member

Choose a reason for hiding this comment

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

nit: consider simplifying example and remove this case which doesn't specify the timeout. setting the default timeout on the builder + comments should be sufficient.

* gRPC timeout is stored in context as a deadline so that when propagated to a new request the remaining time to be
* included in the request can be calculated.
*/
protected static final AsyncContextMap.Key<Instant> GRPC_DEADLINE_KEY = PKG_GRPC_DEADLINE_KEY;
Copy link
Member

Choose a reason for hiding this comment

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

can we keep AsyncContext usage internal? ideally this doesn't have to be exposed in the public API as we may switch to using RequestContext in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing so would require adding another module "servicetalk-grpc-internal' and a class to share the "secret" async context key between modules. I avoided that for now on the expectation that there aren't going to be user implementations of the GrpcServerBuilder and GrcpcClientBuilder

bondolo added 12 commits April 14, 2021 14:53
Motivation:
Some gRPC usages benefit from being able to limit the amount of time a
gRPC call is allowed to execute.

Modifications:
Features are added for time limiting gRPC calls.

Result:
Execution time for gRPC can be more easily managed.
The gRPC deadline async context key is now shared among all uses
Cleanup some of the error generation/translation code for cleaner sharing
@bondolo bondolo merged commit 7aa4751 into apple:main Apr 14, 2021
@idelpivnitskiy
Copy link
Member

LGTM, thanks for the great work!

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