-
Notifications
You must be signed in to change notification settings - Fork 43
Option Values from Supplier and Publisher #137
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
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jeandelavarene
approved these changes
Nov 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 anOption<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.