-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor Jedis and Lettuce RedisConnectionFactory
to SmartLifecycle
beans
#2627
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
Conversation
@@ -415,6 +460,8 @@ protected JedisCluster createCluster(RedisClusterConfiguration clusterConfig, | |||
|
|||
public void destroy() { | |||
|
|||
state.set(State.STOPPING); |
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.
Would it make sense to call stop
as we have quite some duplications?
Assert.state(this.initialized, "JedisConnectionFactory was not initialized through afterPropertiesSet()"); | ||
Assert.state(!this.destroyed, "JedisConnectionFactory was destroyed and cannot be used anymore"); | ||
Assert.state(State.STARTED.equals(state.get()), "JedisConnectionFactory was not initialized through afterPropertiesSet()"); | ||
Assert.state(!State.STOPPED.equals(state.get()), "JedisConnectionFactory was destroyed and cannot be used anymore"); |
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.
We might want to reflect the lifecycle in the messages, as we want to allow starting after stopping, right?
resetConnection(); | ||
dispose(connectionProvider); | ||
dispose(reactiveConnectionProvider); | ||
this.client.close(); |
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.
we should consider the shutdown timeout to prevent long shutdown times.
Duration timeout = clientConfiguration.getShutdownTimeout(); | ||
client.shutdown(quietPeriod.toMillis(), timeout.toMillis(), TimeUnit.MILLISECONDS); | ||
} catch (Exception e) { | ||
try { |
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.
That code could go into stop
and upon destroy it would be neat to reuse what stop
does.
} | ||
state.set(State.DESTROYED); |
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.
👍
|
||
Assert.state(State.STARTED.equals(state.get()), | ||
"LettuceConnectionFactory was not initialized through afterPropertiesSet()"); | ||
Assert.state(!State.STOPPED.equals(state.get()), |
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.
We should reword the messages to reflect started/stopped state. Having a check for destroyed it good as well.
RedisConnectionFactory
to SmartLifecycle
beans
Closes: #2503