-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
api: Add java.time.Duration overloads to CallOptions, AbstractStub #11562
Conversation
…h Duration" This reverts commit ab97045.
|
@@ -95,6 +101,11 @@ public static Deadline after(long duration, TimeUnit units, Ticker ticker) { | |||
return new Deadline(ticker, units.toNanos(duration), true); | |||
} | |||
|
|||
public static Deadline after(Duration duration, Ticker ticker) { | |||
return after(TimeUnit.NANOSECONDS.convert(duration.getSeconds(), TimeUnit.SECONDS), |
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 have a concern about the loss of precision, I have raised a question on Eric's comment to use TimeUnit.NANOSECONDS.convert(duration) instead of Duration.toNano().
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.
As Eric replied, you should be using https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/concurrent/TimeUnit.html#convert(java.time.Duration) and not have to convert using the seconds value.
|
||
import java.time.Duration; | ||
|
||
@Internal |
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.
@internal is used to mark certain classes as should not be used by user code. This class being just a util helper, there is no need to mark it as Internal. Also drop the Internal prefix from the class and file name and make it just TimeUtils.
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.
Well, this is public
in a public package, so the @Internal
is needed.
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.
We need @ExperimentalApi
on all the new public API methods (those receiving Duration).
|
||
import java.time.Duration; | ||
|
||
@Internal |
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.
Well, this is public
in a public package, so the @Internal
is needed.
…ving Duration and reverted LoadBalancer code.
@@ -162,6 +164,12 @@ public String toString() { | |||
return new ScheduledHandle(runnable, future); | |||
} | |||
|
|||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10245") |
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.
These links should point to a new issue created to track stabilizing this API. (See issues with the "experimental API" label for examples.)
Overloading API's containing long, TimeUnit with java.time.Duration
Fixes #10245