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

Extensible transaction definition #159

Closed
wants to merge 3 commits into from
Closed

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Feb 27, 2020

We now expose a Connection.beginTransaction method accepting a TransactionDefinition that can report various transaction attributes. Drivers can choose to provide a vendor-specific extension to specify attributes that apply to their database.

Transaction attributes are optional and expected to be set when starting a transaction when one or more attribute is configured. The callback mechanism allows for a simplified extension model so a library can provide a generic TransactionDefinition implementation that is configured with attributes required for a database without the need to depend on vendor-specific classes.


Todo:

  • Discuss the proposal
  • Documentation

@mp911de mp911de added the status: pending-design-work Needs design work before any code can be developed label Feb 27, 2020
Copy link
Contributor

@elefeint elefeint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the expected use for a custom driver with unique transaction requirements to create our own version of TransactionDefinition, and not to reuse IsolationLevel?

@@ -70,6 +70,18 @@ public static IsolationLevel valueOf(String sql) {
return CONSTANTS.valueOf(sql, false);
}

@Override
public <T> T getAttribute(String name, Class<T> type) {
Assert.requireNonNull(name, "sql must not be null");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sql/name

@mp911de
Copy link
Member Author

mp911de commented Feb 27, 2020

I'm not exactly sure about this. From the perspective of how one works with a driver, they basically don't want to touch driver-specific API in their client library. So a client library would provide a TransactionDefinition instance backed by the way how it's configured (e.g. HashMap, real pojo, proxy, something else).

From a driver perspective, it could make sense to provide a TransactionDefinition to outline its capabilities (e.g. SqlServerTransactionDefinition.builder().transactionName(…).isolationLevel(SNAPSHOT).timeout(…).build()). I'm not quite sure how much these would be used if one works with a client library. When working directly with R2DBC SPI, the driver-provided implementation would make sense. On the other side, we recommend not touching the SPI directly.

@mp911de
Copy link
Member Author

mp911de commented May 4, 2020

The revised proposal changes are now available in this PR. The API surface is reduced to a callback interface for TransactionDefinition along with the specification enhancements.

mp911de added 3 commits May 4, 2020 11:15
TransactionDefinition exposes transaction attributes to be applied when starting a new transaction. Its interface form allows for vendor-specific extensions to apply properties that apply to individual databases.
Reuse Option constants as attribute identifiers. Remove getIsolationLevel and isReadOnly methods. Introduce constants for commonly used attributes. Add specification.
Upgrade to Asciidoctor Maven Plugin 2.0.0-RC.1
@mp911de mp911de force-pushed the transaction-definition branch from e271b5f to e42efbd Compare May 4, 2020 09:15
@mp911de mp911de added type: enhancement A general enhancement and removed status: pending-design-work Needs design work before any code can be developed labels May 4, 2020
@mp911de mp911de changed the base branch from master to main June 24, 2020 09:32
@mp911de mp911de closed this in 36db5a0 Jan 14, 2021
@mp911de mp911de added this to the 0.9.0.M1 milestone Jan 14, 2021
@mp911de mp911de deleted the transaction-definition branch January 14, 2021 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants