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

Allow to configure Redis connection pool #11393

Merged
merged 1 commit into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public RedisAPIProducer(RedisConfig config, Vertx vertx) {
timeout = config.timeout.get().getSeconds();
}

options.setMaxPoolSize(config.maxPoolSize);
options.setMaxPoolWaiting(config.maxPoolWaiting);
options.setPoolRecycleTimeout(Math.toIntExact(config.poolRecycleTimeout.toMillis()));
if (config.poolCleanerInterval.isPresent()) {
options.setPoolCleanerInterval(Math.toIntExact(config.poolCleanerInterval.get().toMillis()));
}

vertxRedisClient = Redis.createClient(vertx, options);
redisAPI = RedisAPI.api(vertxRedisClient);
mutinyRedisClient = io.vertx.mutiny.redis.client.Redis.newInstance(vertxRedisClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,30 @@ public class RedisConfig {
*/
@ConfigItem(defaultValue = "standalone")
public RedisClientType clientType;

/**
* The maximum size of the connection pool. When working with cluster or sentinel.
* <p>
* This value should be at least the total number of cluster member (or number of sentinels + 1)
*/
@ConfigItem(defaultValue = "6")
public int maxPoolSize;

/**
* The maximum waiting requests for a connection from the pool.
*/
@ConfigItem(defaultValue = "24")
public int maxPoolWaiting;

/**
* The duration indicating how often should the connection pool cleaner executes.
*/
@ConfigItem
public Optional<Duration> poolCleanerInterval;

/**
* The timeout for a connection recycling.
*/
@ConfigItem(defaultValue = "15")
public Duration poolRecycleTimeout;
}