-
Notifications
You must be signed in to change notification settings - Fork 1.1k
spanner-jdbc: Step 05 - Util for parsing read-only staleness values #5813
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
spanner-jdbc: Step 05 - Util for parsing read-only staleness values #5813
Conversation
| class ReadOnlyStalenessUtil { | ||
| private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); | ||
| /** Regular expression for parsing RFC3339 times with nanosecond precision. */ | ||
| private static final String RFC3339_REGEX = |
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.
There is an RFC parser in the http client. Can we please switch to that? https://github.com/googleapis/google-http-java-client/blob/master/google-http-client/src/main/java/com/google/api/client/util/DateTime.java
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.
The RFC parser in the http client has millisecond precision, both for parsing and converting to string values. Switching to that one is possible, but would mean that we would not be able to support microsecond or nanosecond precision.
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.
In that case, let's add the enhanced precision to the http client repository, and use the current http client implementation with a todo for now since this is still in a branch.
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've changed the JDBC implementation to use the parser in the http client, and I've added a PR in the http client for adding nanosecond support.
| } | ||
| } | ||
|
|
||
| static final class GetMaxStaleness implements DurationValueGetter { |
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.
minor - can address now or in future commit - I would rename to "MaxStalenessGetter"
| /** | ||
| * Parses an RFC3339 date/time value with millisecond precision and returns this as a {@link | ||
| * Timestamp}. Although {@link Timestamp} has nanosecond precision, this method is only used for | ||
| * parsing read-only staleness values, and more than millisecond precision is not needed for that. |
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.
minor can address in upcoming - I would just replace this with a todo for nanosecond precision
…oogleapis#5813) add util for parsing read-only staleness values
A user can specify a read-only staleness value to use for a read-only transaction by executing a statement that is parsed by the client. This util parses the possible staleness values and can translate these back to text values.