Skip to content

Commit

Permalink
feat(redis): allow to configure redis connection pool
Browse files Browse the repository at this point in the history
  • Loading branch information
machi1990 committed Aug 14, 2020
1 parent 9f121ae commit 81257fb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
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 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 execute.
*/
@ConfigItem
public Optional<Duration> poolCleanerInterval;

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

0 comments on commit 81257fb

Please sign in to comment.