-
Notifications
You must be signed in to change notification settings - Fork 184
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
Conversation
549a5a5
to
520b63f
Compare
servicetalk-examples/docs/modules/ROOT/pages/_partials/nav-versioned.adoc
Outdated
Show resolved
Hide resolved
...amples/grpc/deadline/src/main/java/io/servicetalk/examples/grpc/deadline/DeadlineServer.java
Outdated
Show resolved
Hide resolved
...amples/grpc/deadline/src/main/java/io/servicetalk/examples/grpc/deadline/DeadlineClient.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcClientBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcClientBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcClientBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcClientBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcServerBuilder.java
Show resolved
Hide resolved
The overall approach looks great! My comments mostly about details |
There was a problem hiding this 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.
3e16055
to
34b4cb2
Compare
There was a problem hiding this 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
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcMetadata.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcServerBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcClientBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcServerBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcServerBuilder.java
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/DefaultGrpcClientCallFactory.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcUtils.java
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcUtils.java
Outdated
Show resolved
Hide resolved
// demonstration purposes. | ||
CountDownLatch responseProcessedLatch = new CountDownLatch(2); | ||
|
||
// Make a request using default timeout (this will succeed) |
There was a problem hiding this comment.
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.
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/DefaultGrpcClientCallFactory.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/DefaultGrpcClientCallFactory.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/DefaultGrpcClientCallFactory.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/DefaultGrpcClientMetadata.java
Outdated
Show resolved
Hide resolved
* 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcServerBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-api/src/main/java/io/servicetalk/grpc/api/GrpcUtils.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcClientBuilder.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/main/java/io/servicetalk/grpc/netty/DefaultGrpcServerBuilder.java
Outdated
Show resolved
Hide resolved
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
LGTM, thanks for the great work! |
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.