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: replace individual variables with ConnectionProperty #3322

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Sep 6, 2024

Replace individual variables in ConnectionOptions and ConnectionImpl with
references to ConnectionProperties. This reduces the amount of code bloat,
especially in ConnectionOptions, as all connection property parsing is
now handled by the ConnectionState class in a generic way.

This setup also reduces the amount of code that is needed to add a new
connection property, as there is only one source of truth: the list of
properties in the ConnectionProperties class.

Following steps that will reduce the amount of code bloat further are:

  1. Replace all the regular expressions for SET and SHOW statements with
    a simple token-based parser.
  2. Cleaning up ConnectionOptions further by removing the duplicate list
    of ConnectionProperties there. These can be removed once the JDBC
    driver has been updated to use the new list of properties.

@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 6, 2024
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch from c8e3f5a to 95d3b5f Compare September 7, 2024 09:13
@olavloite olavloite force-pushed the transactional-connection-state branch from 1a223a0 to 1072b1a Compare September 7, 2024 09:19
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch from 95d3b5f to 510bb3e Compare September 7, 2024 09:28
@olavloite olavloite force-pushed the transactional-connection-state branch from 1072b1a to 5276c5e Compare September 7, 2024 09:47
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch from 510bb3e to 51bb5c7 Compare September 7, 2024 09:50
@olavloite olavloite force-pushed the transactional-connection-state branch from 5276c5e to 929466b Compare September 7, 2024 10:05
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch 2 times, most recently from f53ea91 to 82884b5 Compare September 7, 2024 13:39
@olavloite olavloite force-pushed the transactional-connection-state branch from 929466b to b2022c0 Compare September 7, 2024 13:39
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch 2 times, most recently from 1b54384 to 94c2d17 Compare September 7, 2024 15:15
@olavloite olavloite changed the title chore: replace individual variables with ConnectionProperty refactor: replace individual variables with ConnectionProperty Sep 7, 2024
@olavloite olavloite force-pushed the transactional-connection-state branch from b2022c0 to a7dd2e9 Compare September 10, 2024 10:45
…tate

This change adds internal data structures that can be used for transactional
connection state. These data structures also reduces the amount of code that
is needed for each connection property that is added. Connection properties
are currently represented as actual variables in the ConnectionImpl class.
These new data structures removes the need for that.

Only the connection property retryAbortsInternally is refactored to use
the new data structure. All other connection properties will be refactored
in a following change, in order to keep each change as small as possible.

The data structure supports both transactional and non-transactional
connection state. Transactional state is disabled in the current version
in order to be consistent with the current behavior. It will be enabled
in a later change when all connection properties have been refactored
to use the new data structure.
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch from 94c2d17 to 8d91e01 Compare September 10, 2024 10:54
Replace individual variables in ConnectionOptions and ConnectionImpl with
references to ConnectionProperties. This reduces the amount of code bloat,
especially in ConnectionOptions, as all connection property parsing is
now handled by the ConnectionState class in a generic way.

This setup also reduces the amount of code that is needed to add a new
connection property, as there is only one source of truth: the list of
properties in the ConnectionProperties class.

Following steps that will reduce the amount of code bloat further are:
1. Replace all the regular expressions for SET and SHOW statements with
   a simple token-based parser.
2. Cleaning up ConnectionOptions further by removing the duplicate list
   of ConnectionProperties there. These can be removed once the JDBC
   driver has been updated to use the new list of properties.
@olavloite olavloite force-pushed the refactor-connection-variables-to-connection-state branch from 8d91e01 to aec3020 Compare September 10, 2024 11:40
@olavloite olavloite marked this pull request as ready for review September 10, 2024 14:22
@olavloite olavloite requested review from a team as code owners September 10, 2024 14:22
@rahul2393 rahul2393 merged commit 64eed59 into transactional-connection-state Sep 12, 2024
26 checks passed
@rahul2393 rahul2393 deleted the refactor-connection-variables-to-connection-state branch September 12, 2024 08:48
rahul2393 pushed a commit that referenced this pull request Oct 11, 2024
…tate (#3321)

* refactor: add internal data structures for transactional connection state

This change adds internal data structures that can be used for transactional
connection state. These data structures also reduces the amount of code that
is needed for each connection property that is added. Connection properties
are currently represented as actual variables in the ConnectionImpl class.
These new data structures removes the need for that.

Only the connection property retryAbortsInternally is refactored to use
the new data structure. All other connection properties will be refactored
in a following change, in order to keep each change as small as possible.

The data structure supports both transactional and non-transactional
connection state. Transactional state is disabled in the current version
in order to be consistent with the current behavior. It will be enabled
in a later change when all connection properties have been refactored
to use the new data structure.

* refactor: replace individual variables with ConnectionProperty (#3322)

* refactor: add internal data structures for transactional connection state

This change adds internal data structures that can be used for transactional
connection state. These data structures also reduces the amount of code that
is needed for each connection property that is added. Connection properties
are currently represented as actual variables in the ConnectionImpl class.
These new data structures removes the need for that.

Only the connection property retryAbortsInternally is refactored to use
the new data structure. All other connection properties will be refactored
in a following change, in order to keep each change as small as possible.

The data structure supports both transactional and non-transactional
connection state. Transactional state is disabled in the current version
in order to be consistent with the current behavior. It will be enabled
in a later change when all connection properties have been refactored
to use the new data structure.

* refactor: replace individual variables with ConnectionProperty

Replace individual variables in ConnectionOptions and ConnectionImpl with
references to ConnectionProperties. This reduces the amount of code bloat,
especially in ConnectionOptions, as all connection property parsing is
now handled by the ConnectionState class in a generic way.

This setup also reduces the amount of code that is needed to add a new
connection property, as there is only one source of truth: the list of
properties in the ConnectionProperties class.

Following steps that will reduce the amount of code bloat further are:
1. Replace all the regular expressions for SET and SHOW statements with
   a simple token-based parser.
2. Cleaning up ConnectionOptions further by removing the duplicate list
   of ConnectionProperties there. These can be removed once the JDBC
   driver has been updated to use the new list of properties.

* feat: enable transactional connection state as an opt-in (#3326)

* refactor: add internal data structures for transactional connection state

This change adds internal data structures that can be used for transactional
connection state. These data structures also reduces the amount of code that
is needed for each connection property that is added. Connection properties
are currently represented as actual variables in the ConnectionImpl class.
These new data structures removes the need for that.

Only the connection property retryAbortsInternally is refactored to use
the new data structure. All other connection properties will be refactored
in a following change, in order to keep each change as small as possible.

The data structure supports both transactional and non-transactional
connection state. Transactional state is disabled in the current version
in order to be consistent with the current behavior. It will be enabled
in a later change when all connection properties have been refactored
to use the new data structure.

* refactor: replace individual variables with ConnectionProperty

Replace individual variables in ConnectionOptions and ConnectionImpl with
references to ConnectionProperties. This reduces the amount of code bloat,
especially in ConnectionOptions, as all connection property parsing is
now handled by the ConnectionState class in a generic way.

This setup also reduces the amount of code that is needed to add a new
connection property, as there is only one source of truth: the list of
properties in the ConnectionProperties class.

Following steps that will reduce the amount of code bloat further are:
1. Replace all the regular expressions for SET and SHOW statements with
   a simple token-based parser.
2. Cleaning up ConnectionOptions further by removing the duplicate list
   of ConnectionProperties there. These can be removed once the JDBC
   driver has been updated to use the new list of properties.

* refactor: add internal data structures for transactional connection state

This change adds internal data structures that can be used for transactional
connection state. These data structures also reduces the amount of code that
is needed for each connection property that is added. Connection properties
are currently represented as actual variables in the ConnectionImpl class.
These new data structures removes the need for that.

Only the connection property retryAbortsInternally is refactored to use
the new data structure. All other connection properties will be refactored
in a following change, in order to keep each change as small as possible.

The data structure supports both transactional and non-transactional
connection state. Transactional state is disabled in the current version
in order to be consistent with the current behavior. It will be enabled
in a later change when all connection properties have been refactored
to use the new data structure.

* refactor: replace individual variables with ConnectionProperty

Replace individual variables in ConnectionOptions and ConnectionImpl with
references to ConnectionProperties. This reduces the amount of code bloat,
especially in ConnectionOptions, as all connection property parsing is
now handled by the ConnectionState class in a generic way.

This setup also reduces the amount of code that is needed to add a new
connection property, as there is only one source of truth: the list of
properties in the ConnectionProperties class.

Following steps that will reduce the amount of code bloat further are:
1. Replace all the regular expressions for SET and SHOW statements with
   a simple token-based parser.
2. Cleaning up ConnectionOptions further by removing the duplicate list
   of ConnectionProperties there. These can be removed once the JDBC
   driver has been updated to use the new list of properties.

* feat: enable transactional connection state as an opt-in

This change enables transactional connection state for the Connection API.
It can be enabled by default for PostgreSQL-dialect databases using a system
property, and is always an opt-in for GoogleSQL-dialect databases.

Transactional connection state can be enabled for any database connection
with the `connection_state_type` connection STARTUP property.

* chore: remove misleading comment

* chore: generate libraries at Tue Oct  8 12:50:40 UTC 2024

---------

Co-authored-by: cloud-java-bot <[email protected]>
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.

2 participants