-
Notifications
You must be signed in to change notification settings - Fork 124
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
Support setting deadline per-call #1838
Conversation
Hi @longshorej, Thank you for your contribution! We really value the time you've taken to put this together. We see that you have signed the Lightbend Contributors License Agreement before, however, the CLA has changed since you last signed it. |
0eb2825
to
b73151f
Compare
Hi @longshorej, Thank you for your contribution! We really value the time you've taken to put this together. We see that you have signed the Lightbend Contributors License Agreement before, however, the CLA has changed since you last signed it. |
b73151f
to
0b901c4
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.
Nice! Will need Java DSL API in akka.grpc.javadsl.SingleResponseRequestBuilder
as well (using Java duration).
Ah, got it. I will add this sometime in the next couple days. Thanks. |
Hi @johanandren, I added the Java API methods, as well as streaming for Java+Scala. |
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.
looking good
* Set the deadline for this call | ||
* @return A new request builder, that will use the supplied deadline when invoked | ||
*/ | ||
def setDeadline(deadline: Duration): SingleResponseRequestBuilder[Req, Res] |
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.
Should we use FiniteDuration
here instead. Always somewhat confusing what non finite Duration means.
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.
I went to make this change but found that GrpcClientSettings#deadline
is already typed as Duration
and supports supplying infinite, which means no timeout -- in NettyClientUtils
it's implemented as follows:
@InternalApi private[akka] def callOptionsWithDeadline(
defaultOptions: CallOptions,
settings: GrpcClientSettings): CallOptions =
settings.deadline match {
case d: FiniteDuration => defaultOptions.withDeadlineAfter(d.toMillis, TimeUnit.MILLISECONDS)
case _ => defaultOptions
}
...so, I updated the call sites to check isFinite
/null (Scala/Java) and clear timeout if its infinite, which I think is more consistent with how the settings are parsed. Let me know what you think though - happy to make it FiniteDuration
if you think that's better.
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.
good, thanks
new ScalaBidirectionalStreamingRequestBuilder[I, O]( | ||
descriptor, | ||
channel, | ||
defaultOptions.withDeadlineAfter(deadline.toMillis, TimeUnit.MILLISECONDS), |
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.
see my comment about FiniteDuration, this will probably fail otherwise for some non finite durations
could you also add some mima filters:
|
Added |
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.
LGTM
* Set the deadline for this call | ||
* @return A new request builder, that will use the supplied deadline when invoked | ||
*/ | ||
def setDeadline(deadline: Duration): SingleResponseRequestBuilder[Req, Res] |
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.
good, thanks
sorry, we released a milestone, so latest is 2.4.0-M1 |
Adds a setDeadline method to the request builder, so that it can optionally be specified per call.
64f9ddc
to
e1887a1
Compare
Done! |
Thanks |
Adds a setDeadline method to the request builder, so that it can optionally be specified per call.
Adds a setDeadline method to the request builder, so that it can optionally be specified per call.