@@ -153,19 +153,22 @@ public struct ValkeyClientConfiguration: Sendable {
153153 }
154154 }
155155
156- /// Determine how replicas are chosen for readonly commands
157- public struct ReadOnlyReplicaSelection : Sendable {
156+ /// Determine how nodes are chosen for readonly commands
157+ public struct ReadOnlyCommandNodeSelection : Sendable {
158158 enum _Internal {
159- case none
160- case cycle
159+ case primary
160+ case cycleReplicas
161+ case cycleAllNodes
161162 }
162163
163164 let value : _Internal
164165
165- /// Do not use readonly replicas
166- public static var none : Self { . init( value: . none ) }
166+ /// Always use the primary node
167+ public static var primary : Self { . init( value: . primary ) }
167168 /// Cycle through replicas
168- public static var cycle : Self { . init( value: . cycle) }
169+ public static var cycleReplicas : Self { . init( value: . cycleReplicas) }
170+ /// Cycle through primary and replicas
171+ public static var cycleAllNodes : Self { . init( value: . cycleAllNodes) }
169172 }
170173
171174 /// The authentication credentials for the connection.
@@ -186,15 +189,13 @@ public struct ValkeyClientConfiguration: Sendable {
186189 /// The TLS to use for the Valkey connection.
187190 public var tls : TLS
188191
189- /// Determine how we chose replicas for readonly commands
190- ///
191- /// A nil value indicates we do not want to use readonly replicas
192+ /// Determine how we chose nodes for readonly commands
192193 ///
193194 /// Cluster by default will redirect commands from replica nodes to the primary node.
194- /// Setting this value will allow replicas to run readonly commands. This will reduce
195- /// load on your primary nodes but there is a chance you will receive stale data as
196- /// the replica is not up to date.
197- public var readOnlyReplicaSelection : ReadOnlyReplicaSelection
195+ /// Setting this value to something other than ``ReadOnlyCommandNodeSelection/primary``
196+ /// will allow replicas to run readonly commands. This will reduce load on your primary
197+ /// nodes but there is a chance you will receive stale data as the replica is not up to date.
198+ public var readOnlyCommandNodeSelection : ReadOnlyCommandNodeSelection
198199
199200 #if DistributedTracingSupport
200201 /// The distributed tracing configuration to use for the Valkey connection.
@@ -221,7 +222,7 @@ public struct ValkeyClientConfiguration: Sendable {
221222 commandTimeout: Duration = . seconds( 30 ) ,
222223 blockingCommandTimeout: Duration = . seconds( 120 ) ,
223224 tls: TLS = . disable,
224- readOnlyReplicaSelection : ReadOnlyReplicaSelection = . none
225+ readOnlyCommandNodeSelection : ReadOnlyCommandNodeSelection = . primary
225226 ) {
226227 self . authentication = authentication
227228 self . connectionPool = connectionPool
@@ -230,6 +231,6 @@ public struct ValkeyClientConfiguration: Sendable {
230231 self . commandTimeout = commandTimeout
231232 self . blockingCommandTimeout = blockingCommandTimeout
232233 self . tls = tls
233- self . readOnlyReplicaSelection = readOnlyReplicaSelection
234+ self . readOnlyCommandNodeSelection = readOnlyCommandNodeSelection
234235 }
235236}
0 commit comments