-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add maxLifetime
to reactive datasource configurations
#34985
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
53 changes: 53 additions & 0 deletions
53
...datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/UnitisedTime.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.quarkus.reactive.datasource.runtime; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class UnitisedTime { | ||
|
||
public final int value; | ||
public final TimeUnit unit; | ||
|
||
public UnitisedTime(int value, TimeUnit unit) { | ||
this.value = value; | ||
this.unit = unit; | ||
} | ||
|
||
/** | ||
* Convert a {@link Duration} to a {@link UnitisedTime} with the smallest possible | ||
* {@link TimeUnit} starting from {@link TimeUnit#MILLISECONDS}. | ||
* | ||
* @param duration Duration to convert | ||
* | ||
* @return UnitisedTime | ||
*/ | ||
public static UnitisedTime unitised(Duration duration) { | ||
if (duration.isNegative()) { | ||
throw new IllegalArgumentException("Duration cannot be negative."); | ||
} | ||
|
||
long millis = duration.toMillis(); | ||
if (millis < Integer.MAX_VALUE) { | ||
return new UnitisedTime((int) millis, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
long seconds = duration.getSeconds(); | ||
if (seconds < Integer.MAX_VALUE) { | ||
return new UnitisedTime((int) seconds, TimeUnit.SECONDS); | ||
} | ||
|
||
long minutes = duration.toMinutes(); | ||
if (minutes < Integer.MAX_VALUE) { | ||
return new UnitisedTime((int) minutes, TimeUnit.MINUTES); | ||
} | ||
|
||
long hours = duration.toHours(); | ||
if (hours < Integer.MAX_VALUE) { | ||
return new UnitisedTime((int) hours, TimeUnit.HOURS); | ||
} | ||
|
||
long days = duration.toDays(); | ||
return new UnitisedTime((int) days, TimeUnit.DAYS); | ||
|
||
} | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what's different with the RabbitMQ extension? If the CredentialsProvider has the
"expires-at
property, couldn't we use the value to configure the pool correctly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RabbitMQ connections supports this automatically, it has built support for dynamic credentials.
Vert.x connection pooling does not support this. I made the PR to add
max-lifetime
to the Vert.x pool and in its current state I believe it would be hard to support this type of feature. Currently theSqlConnectionPool
doesn't allow configuration of per-connection properties. If we gain the ability to set properties (specifically something likemax lifetime
) per connection this could be implemented