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

Option Values from Supplier and Publisher #137

Merged
merged 17 commits into from
Nov 3, 2023

Conversation

Michael-A-McMahon
Copy link
Member

This branch allows a java.util.function.Supplier or an org.reactivestreams.Publisher to provide the value of an io.r2dbc.spi.Option. This is useful for values which change over time, such as a password which gets rotated, or an access token which gets refreshed. Users will no longer need to recreate their connection pool in order to update the value of an option. Instead, their Supplier or Publisher can provide updated values for new connections.

With a small number of exceptions, any Option can be configured to have a Supplier or Publisher provide the value. In order to call ConnectionFactoryOptions.Builder.option(Option, T) with T being a Supplier or Publisher, users must cast the generic type of the Option accordingly. For instance, if a user wants to call this method with ConnectionFactoryOptions.PASSWORD and a Supplier, then PASSWORD must be cast from an Option<CharSequence> to an Option<Supplier<CharSequence>>. New methods which perform these casts are added to the exported API of OracleR2dbcOptions.

Casting the generic type of an Option is safe so long as no other component besides Oracle R2DBC will consume that option's value. Casting is not safe for the DRIVER option, which is consumed as a String by io.r2dbc.ConnectionFactories. Casting is also not safe for the PROTOCOL option, which consumed as a String by r2dbc-pool.

In previous releases, Oracle R2DBC was specified to not retain any reference to any option's value after ConnectionFactories.create(ConnectionFactoryOptions) had returned. This specification does not apply if a Supplier or
Publisher provides the value of at least one Option. In this case, references to all Option values are permanently retained by the ConnectionFactory. This limitation allows the implementation of this feature to remain fairly simple. If this limitation is not acceptable to users, then I will investigate alternative implementations which can resolve it.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 30, 2023
@Michael-A-McMahon Michael-A-McMahon self-assigned this Oct 30, 2023
@Michael-A-McMahon Michael-A-McMahon linked an issue Oct 30, 2023 that may be closed by this pull request
@Michael-A-McMahon Michael-A-McMahon merged commit 50c85a6 into main Nov 3, 2023
3 checks passed
@Michael-A-McMahon Michael-A-McMahon deleted the 84-option-publisher branch November 3, 2023 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot change password of connection factory after creation
2 participants