Skip to content

Commit

Permalink
Merge pull request #30865 from gsmet/improve-reactive-pool-size
Browse files Browse the repository at this point in the history
Simplify reactive pool size configuration
  • Loading branch information
gsmet authored Feb 7, 2023
2 parents e6f3691 + 9be74d9 commit 96605e8
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class DataSourceReactiveRuntimeConfig {
/**
* The datasource pool maximum size.
*/
@ConfigItem(defaultValueDocumentation = "20")
public OptionalInt maxSize = OptionalInt.empty();
@ConfigItem(defaultValue = "20")
public int maxSize = 20;

/**
* When a new connection object is created, the pool assigns it an event loop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
PoolOptions poolOptions;
poolOptions = new PoolOptions();

if (dataSourceReactiveRuntimeConfig.maxSize.isPresent()) {
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize.getAsInt());
} else {
poolOptions.setMaxSize(20);
}
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize);

if (dataSourceReactiveRuntimeConfig.idleTimeout.isPresent()) {
int idleTimeout = Math.toIntExact(dataSourceReactiveRuntimeConfig.idleTimeout.get().toMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
PoolOptions poolOptions;
poolOptions = new PoolOptions();

if (dataSourceReactiveRuntimeConfig.maxSize.isPresent()) {
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize.getAsInt());
} else {
poolOptions.setMaxSize(20);
}
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize);

if (dataSourceReactiveRuntimeConfig.idleTimeout.isPresent()) {
int idleTimeout = Math.toIntExact(dataSourceReactiveRuntimeConfig.idleTimeout.get().toMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
PoolOptions poolOptions;
poolOptions = new PoolOptions();

if (dataSourceReactiveRuntimeConfig.maxSize.isPresent()) {
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize.getAsInt());
} else {
poolOptions.setMaxSize(20);
}
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize);

if (dataSourceReactiveRuntimeConfig.idleTimeout.isPresent()) {
int idleTimeout = Math.toIntExact(dataSourceReactiveRuntimeConfig.idleTimeout.get().toMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
PoolOptions poolOptions;
poolOptions = new PoolOptions();

if (dataSourceReactiveRuntimeConfig.maxSize.isPresent()) {
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize.getAsInt());
} else {
poolOptions.setMaxSize(20);
}
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize);

if (dataSourceReactiveRuntimeConfig.idleTimeout.isPresent()) {
int idleTimeout = Math.toIntExact(dataSourceReactiveRuntimeConfig.idleTimeout.get().toMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ private PoolOptions toPoolOptions(Integer eventLoopCount,
PoolOptions poolOptions;
poolOptions = new PoolOptions();

if (dataSourceReactiveRuntimeConfig.maxSize.isPresent()) {
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize.getAsInt());
} else {
poolOptions.setMaxSize(20);
}
poolOptions.setMaxSize(dataSourceReactiveRuntimeConfig.maxSize);

if (dataSourceReactiveRuntimeConfig.idleTimeout.isPresent()) {
int idleTimeout = Math.toIntExact(dataSourceReactiveRuntimeConfig.idleTimeout.get().toMillis());
Expand Down

0 comments on commit 96605e8

Please sign in to comment.