Skip to content

Commit

Permalink
Un-deprecate ClientOptions.pingBeforeActivateConnection #1208
Browse files Browse the repository at this point in the history
pingBeforeActivateConnection turns out to be useful when using RESP2 in cases where the connection authentication should be delayed. Another case is when the PING should be used as auth PING to test whether a reconnect was successful.

Related ticket: #1201.
  • Loading branch information
mp911de committed Jan 31, 2020
1 parent 6371392 commit 9667bb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/main/java/io/lettuce/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ protected Builder() {
*
* @param pingBeforeActivateConnection true/false
* @return {@code this}
* @deprecated since 5.2. PING during connection handshake is mandatory with RESP3.
*/
@Deprecated
public Builder pingBeforeActivateConnection(boolean pingBeforeActivateConnection) {
this.pingBeforeActivateConnection = pingBeforeActivateConnection;
return this;
Expand Down Expand Up @@ -335,7 +333,7 @@ public ClientOptions.Builder mutate() {
builder.autoReconnect(isAutoReconnect()).bufferUsageRatio(getBufferUsageRatio())
.cancelCommandsOnReconnectFailure(isCancelCommandsOnReconnectFailure())
.disconnectedBehavior(getDisconnectedBehavior()).publishOnScheduler(isPublishOnScheduler())
.protocolVersion(getConfiguredProtocolVersion()).pingBeforeActivateConnection(isPingBeforeActivateConnection())
.pingBeforeActivateConnection(isPingBeforeActivateConnection()).protocolVersion(getConfiguredProtocolVersion())
.requestQueueSize(getRequestQueueSize()).socketOptions(getSocketOptions()).sslOptions(getSslOptions())
.suspendReconnectOnProtocolFailure(isSuspendReconnectOnProtocolFailure()).timeoutOptions(getTimeoutOptions());

Expand All @@ -349,9 +347,7 @@ public ClientOptions.Builder mutate() {
* unless forcing to use the RESP 2 protocol version.
*
* @return {@literal true} if {@literal PING} barrier is enabled.
* @deprecated since 5.2. PING during connection handshake is mandatory with RESP3.
*/
@Deprecated
public boolean isPingBeforeActivateConnection() {
return pingBeforeActivateConnection;
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/io/lettuce/core/cluster/ClusterClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ public Builder topologyRefreshOptions(ClusterTopologyRefreshOptions topologyRefr
return this;
}

@Override
public Builder pingBeforeActivateConnection(boolean pingBeforeActivateConnection) {
super.pingBeforeActivateConnection(pingBeforeActivateConnection);
return this;
}

@Override
public Builder protocolVersion(ProtocolVersion protocolVersion) {
super.protocolVersion(protocolVersion);
Expand Down Expand Up @@ -269,8 +275,8 @@ public ClusterClientOptions.Builder mutate() {
builder.autoReconnect(isAutoReconnect()).bufferUsageRatio(getBufferUsageRatio())
.cancelCommandsOnReconnectFailure(isCancelCommandsOnReconnectFailure())
.disconnectedBehavior(getDisconnectedBehavior()).publishOnScheduler(isPublishOnScheduler())
.protocolVersion(getConfiguredProtocolVersion()).requestQueueSize(getRequestQueueSize())
.socketOptions(getSocketOptions()).sslOptions(getSslOptions())
.pingBeforeActivateConnection(isPingBeforeActivateConnection()).protocolVersion(getConfiguredProtocolVersion())
.requestQueueSize(getRequestQueueSize()).socketOptions(getSocketOptions()).sslOptions(getSslOptions())
.suspendReconnectOnProtocolFailure(isSuspendReconnectOnProtocolFailure()).timeoutOptions(getTimeoutOptions())
.validateClusterNodeMembership(isValidateClusterNodeMembership()).maxRedirects(getMaxRedirects())
.topologyRefreshOptions(getTopologyRefreshOptions());
Expand Down

0 comments on commit 9667bb5

Please sign in to comment.