Skip to content

Commit

Permalink
Rename ReadFrom.NEAREST to LOWEST_LATENCY to clarify its function…
Browse files Browse the repository at this point in the history
…ality #1997

Introduce LOWEST_LATENCY and deprecate NEAREST.
  • Loading branch information
mp911de committed Feb 25, 2022
1 parent c918754 commit e1e24ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 19 additions & 4 deletions src/main/java/io/lettuce/core/ReadFrom.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,24 @@ public abstract class ReadFrom {
public static final ReadFrom SLAVE = REPLICA;

/**
* Setting to read from the nearest node.
* Setting to read from the node with the lowest latency during topology discovery. Note that latency measurements are
* momentary snapshots that can change in rapid succession. Requires dynamic refresh sources to obtain topologies and
* latencies from all nodes in the cluster.
*
* @since 6.1.7
*/
public static final ReadFrom LOWEST_LATENCY = new ReadFromImpl.ReadFromLowestCommandLatency();

/**
* Setting to read from the node with the lowest latency during topology discovery. Note that latency measurements are
* momentary snapshots that can change in rapid succession. Requires dynamic refresh sources to obtain topologies and
* latencies from all nodes in the cluster.
*
* @deprecated since 6.1.7 as we're renaming this setting to {@link #LOWEST_LATENCY} for more clarity what this setting
* actually represents.
*/
public static final ReadFrom NEAREST = new ReadFromImpl.ReadFromNearest();
@Deprecated
public static final ReadFrom NEAREST = LOWEST_LATENCY;

/**
* Setting to read from any node.
Expand Down Expand Up @@ -198,8 +213,8 @@ public static ReadFrom valueOf(String name) {
return REPLICA_PREFERRED;
}

if (name.equalsIgnoreCase("nearest")) {
return NEAREST;
if (name.equalsIgnoreCase("nearest") || name.equalsIgnoreCase("lowestLatency")) {
return LOWEST_LATENCY;
}

if (name.equalsIgnoreCase("any")) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/lettuce/core/ReadFromImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ static final class ReadFromReplicaPreferred extends OrderedPredicateReadFromAdap
}

/**
* Read from nearest node.
* Read from the node with the lowest latency during topology discovery. Note that latency measurements are momentary
* snapshots that can change in rapid succession. Requires dynamic refresh sources to obtain topologies and latencies from
* all nodes in the cluster.
*/
static final class ReadFromNearest extends ReadFrom {
static final class ReadFromLowestCommandLatency extends ReadFrom {

@Override
public List<RedisNodeDescription> select(Nodes nodes) {
Expand Down

0 comments on commit e1e24ca

Please sign in to comment.