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

refactor: use java.time.Duration in Connection API #3324

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Sep 9, 2024

Use java.time.Duration internally in the Connection API, as that is the value that is used in the public API of Connection. For example, the Connection#setMaxCommitDelay(java.time.Duration) method uses this type in the public API.

Refactoring the internal classes to also use this type makes it easier to plug these properties into a generic framework for connection state.

This pull request also cleans up the following:

  1. The DurationConverter and PgDurationConverter are combined into one class, as they do the same thing, and were almost duplicate of each other.
  2. Adds support for specifying a duration purely as a number (e.g. 100). A number without a time unit is interpreted as milliseconds. This was already supported by PgDurationConverter, but was also implicitly supported for GoogleSQL durations when they were specified as part of the connection URL. E.g. adding maxCommitDelay=100 in the connection URL was already allowed, and is interpreted as 100ms.

This pull request is a pre-requisite for #3322

Use java.time.Duration internally in the Connection API, as that is
the value that is used in the public API of Connection. For example,
the `Connection#setMaxCommitDelay(java.time.Duration)` method uses
this type in the public API.

Refactoring the internal classes to also use this type makes it
easier to plug these properties into a generic framework for
connection state.
@olavloite olavloite requested review from a team as code owners September 9, 2024 10:25
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: spanner Issues related to the googleapis/java-spanner API. labels Sep 9, 2024
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 9, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 9, 2024
@olavloite olavloite merged commit 7adbfa6 into main Sep 12, 2024
33 checks passed
@olavloite olavloite deleted the use-java-util-time-duration-in-connection-api branch September 12, 2024 14:35
lqiu96 pushed a commit that referenced this pull request Sep 19, 2024
Use java.time.Duration internally in the Connection API, as that is
the value that is used in the public API of Connection. For example,
the `Connection#setMaxCommitDelay(java.time.Duration)` method uses
this type in the public API.

Refactoring the internal classes to also use this type makes it
easier to plug these properties into a generic framework for
connection state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants