Start RedisConnectionFactory through afterPropertiesSet.
This commit restores the behaviour of RedisConnectionFactories eager initialization via afterPropertiesSet. Additionally it is now possible to modify the lifecycle phase. Closes #2635 Original pull request: #2636
This commit is contained in:
committed by
Mark Paluch
parent
ce3c439a17
commit
d98afb9154
@@ -118,6 +118,8 @@ public class JedisConnectionFactory
|
||||
private @Nullable ClusterTopologyProvider topologyProvider;
|
||||
private @Nullable ClusterCommandExecutor clusterCommandExecutor;
|
||||
|
||||
private int phase = DEFAULT_PHASE - 10;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link JedisConnectionFactory} instance with default settings (default connection pooling).
|
||||
*/
|
||||
@@ -262,7 +264,11 @@ public class JedisConnectionFactory
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
|
||||
clientConfig = createClientConfig(getDatabase(), getRedisUsername(), getRedisPassword());
|
||||
if(isAutoStartup()) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
JedisClientConfig createSentinelClientConfig(SentinelConfiguration sentinelConfiguration) {
|
||||
@@ -853,6 +859,21 @@ public class JedisConnectionFactory
|
||||
return RedisConfiguration.isClusterConfiguration(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the lifecycle phase for pausing and resuming this executor.
|
||||
* The default is {@link #DEFAULT_PHASE} - 10.
|
||||
* @since 3.2
|
||||
* @see SmartLifecycle#getPhase()
|
||||
*/
|
||||
public void setPhase(int phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisSentinelConnection getSentinelConnection() {
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ public class LettuceConnectionFactory implements RedisConnectionFactory, Reactiv
|
||||
|
||||
private PipeliningFlushPolicy pipeliningFlushPolicy = PipeliningFlushPolicy.flushEachCommand();
|
||||
|
||||
private int phase = DEFAULT_PHASE - 10;
|
||||
|
||||
/**
|
||||
* Lifecycle state of this factory.
|
||||
*/
|
||||
@@ -400,7 +402,9 @@ public class LettuceConnectionFactory implements RedisConnectionFactory, Reactiv
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// customization hook. initialization happens in start
|
||||
if(isAutoStartup()) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1097,6 +1101,21 @@ public class LettuceConnectionFactory implements RedisConnectionFactory, Reactiv
|
||||
return RedisConfiguration.isClusterConfiguration(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the lifecycle phase for pausing and resuming this executor.
|
||||
* The default is {@link #DEFAULT_PHASE} - 10.
|
||||
* @since 3.2
|
||||
* @see SmartLifecycle#getPhase()
|
||||
*/
|
||||
public void setPhase(int phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the shared connection using {@literal byte[]} encoding for imperative API use. {@literal null} if
|
||||
* {@link #getShareNativeConnection() connection sharing} is disabled or when connected to Redis Cluster.
|
||||
|
||||
Reference in New Issue
Block a user