DATAREDIS-918 - Enable Lettuce's global timeouts by default.
LettuceClientConfiguration now enables Lettuce's global timeouts by default to enable timeouts using the reactive API. This change prevents hanging Redis commands due to a blocked connection or when Redis is down. Timeouts are enabled through defaulting so setting ClientOptions or ClusterClientOptions overrides this behavior. Original Pull Request: #381
This commit is contained in:
committed by
Christoph Strobl
parent
8f209e3668
commit
62e48be873
@@ -18,6 +18,7 @@ package org.springframework.data.redis.connection.lettuce;
|
||||
import io.lettuce.core.ClientOptions;
|
||||
import io.lettuce.core.ReadFrom;
|
||||
import io.lettuce.core.RedisURI;
|
||||
import io.lettuce.core.TimeoutOptions;
|
||||
import io.lettuce.core.resource.ClientResources;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -37,7 +38,7 @@ import org.springframework.util.Assert;
|
||||
* <li>Whether to verify peers using SSL</li>
|
||||
* <li>Whether to use StartTLS</li>
|
||||
* <li>Optional {@link ClientResources}</li>
|
||||
* <li>Optional {@link ClientOptions}</li>
|
||||
* <li>Optional {@link ClientOptions}, defaults to {@link ClientOptions} with enabled {@link TimeoutOptions}.</li>
|
||||
* <li>Optional client name</li>
|
||||
* <li>Optional {@link ReadFrom}. Enables Master/Replica operations if configured.</li>
|
||||
* <li>Client {@link Duration timeout}</li>
|
||||
@@ -132,7 +133,7 @@ public interface LettuceClientConfiguration {
|
||||
* <dt>Start TLS</dt>
|
||||
* <dd>no</dd>
|
||||
* <dt>Client Options</dt>
|
||||
* <dd>none</dd>
|
||||
* <dd>{@link ClientOptions} with enabled {@link io.lettuce.core.TimeoutOptions}</dd>
|
||||
* <dt>Client Resources</dt>
|
||||
* <dd>none</dd>
|
||||
* <dt>Client name</dt>
|
||||
@@ -163,7 +164,7 @@ public interface LettuceClientConfiguration {
|
||||
boolean verifyPeer = true;
|
||||
boolean startTls;
|
||||
@Nullable ClientResources clientResources;
|
||||
@Nullable ClientOptions clientOptions;
|
||||
ClientOptions clientOptions = ClientOptions.builder().timeoutOptions(TimeoutOptions.enabled()).build();
|
||||
@Nullable String clientName;
|
||||
@Nullable ReadFrom readFrom;
|
||||
Duration timeout = Duration.ofSeconds(RedisURI.DEFAULT_TIMEOUT);
|
||||
|
||||
@@ -59,7 +59,7 @@ public interface LettucePoolingClientConfiguration extends LettuceClientConfigur
|
||||
* <dt>Start TLS</dt>
|
||||
* <dd>no</dd>
|
||||
* <dt>Client Options</dt>
|
||||
* <dd>none</dd>
|
||||
* <dd>{@link ClientOptions} with enabled {@link io.lettuce.core.TimeoutOptions}</dd>
|
||||
* <dt>Client Resources</dt>
|
||||
* <dd>none</dd>
|
||||
* <dt>Connect Timeout</dt>
|
||||
|
||||
Reference in New Issue
Block a user