@@ -14,8 +14,8 @@ import (
1414 "github.com/redis/go-redis/v9/internal"
1515)
1616
17- // AutoPipelineConfig configures the autopipelining behavior.
18- type AutoPipelineConfig struct {
17+ // AutoPipelineOptions configures the autopipelining behavior.
18+ type AutoPipelineOptions struct {
1919 // MaxBatchSize is the target batch size: the accumulator stops waiting for
2020 // more commands once the shard queue reaches it, so a batch flushes promptly
2121 // instead of lingering. It is a soft threshold, not a hard cap — under heavy
@@ -134,22 +134,22 @@ func numAutoPipelineShards() int {
134134 return n
135135}
136136
137- // DefaultAutoPipelineConfig returns the default autopipelining configuration.
137+ // DefaultAutoPipelineOptions returns the default autopipelining configuration.
138138//
139139// The default is ordered: MaxConcurrentBatches is 1, so batches execute
140140// serially in submit order (a single ordered command stream) while still
141141// reaching high throughput via deep pipelines when callers submit in windows.
142142// To trade ordering for parallel-batch throughput, set MaxConcurrentBatches > 1
143143// together with Unordered: true.
144- func DefaultAutoPipelineConfig () * AutoPipelineConfig {
145- return & AutoPipelineConfig {
144+ func DefaultAutoPipelineOptions () * AutoPipelineOptions {
145+ return & AutoPipelineOptions {
146146 MaxBatchSize : 200 ,
147147 MaxConcurrentBatches : 1 , // ordered by default
148148 MaxFlushDelay : 0 , // lowest latency; no coalescing wait (batch via in-flight backpressure)
149149 }
150150}
151151
152- // DefaultBlockingAutoPipelineConfig returns the default config for the
152+ // DefaultBlockingAutoPipelineOptions returns the default config for the
153153// blocking face (Client.AutoPipeline). It uses a single ordered batch stream
154154// (MaxConcurrentBatches: 1). Counterintuitively this maximizes throughput AND
155155// minimizes latency for the blocking face: with one batch in flight, callers whose
@@ -162,8 +162,8 @@ func DefaultAutoPipelineConfig() *AutoPipelineConfig {
162162// per round-trip while latency rises. For maximum throughput use the async face
163163// (AsyncAutoPipeline) with a window of in-flight commands (inflight>1); it keeps
164164// MaxConcurrentBatches: 1 as well.
165- func DefaultBlockingAutoPipelineConfig () * AutoPipelineConfig {
166- return & AutoPipelineConfig {
165+ func DefaultBlockingAutoPipelineOptions () * AutoPipelineOptions {
166+ return & AutoPipelineOptions {
167167 MaxBatchSize : 300 ,
168168 MaxConcurrentBatches : 1 ,
169169 }
@@ -172,29 +172,29 @@ func DefaultBlockingAutoPipelineConfig() *AutoPipelineConfig {
172172// Validate reports whether the configuration is self-consistent. It returns an
173173// error if MaxConcurrentBatches > 1 without Unordered: true — raising
174174// concurrency gives up command ordering, so the caller must opt in explicitly.
175- func (cfg * AutoPipelineConfig ) Validate () error {
175+ func (cfg * AutoPipelineOptions ) Validate () error {
176176 if cfg .MaxConcurrentBatches > 1 && ! cfg .Unordered {
177- return fmt .Errorf ("redis: AutoPipelineConfig .MaxConcurrentBatches=%d requires Unordered:true " +
177+ return fmt .Errorf ("redis: AutoPipelineOptions .MaxConcurrentBatches=%d requires Unordered:true " +
178178 "(parallel batches do not preserve command ordering); set Unordered:true to allow it, " +
179179 "or keep MaxConcurrentBatches=1 for an ordered stream" , cfg .MaxConcurrentBatches )
180180 }
181181 // Reject obviously-wrong negatives so a typo surfaces at construction rather
182182 // than being silently coerced to a default. Zero is allowed and means "use
183183 // the default" (MaxBatchSize) or "no delay" (MaxFlushDelay).
184184 if cfg .MaxBatchSize < 0 {
185- return fmt .Errorf ("redis: AutoPipelineConfig .MaxBatchSize=%d must be >= 0" , cfg .MaxBatchSize )
185+ return fmt .Errorf ("redis: AutoPipelineOptions .MaxBatchSize=%d must be >= 0" , cfg .MaxBatchSize )
186186 }
187187 if cfg .MaxConcurrentBatches < 0 {
188- return fmt .Errorf ("redis: AutoPipelineConfig .MaxConcurrentBatches=%d must be >= 0" , cfg .MaxConcurrentBatches )
188+ return fmt .Errorf ("redis: AutoPipelineOptions .MaxConcurrentBatches=%d must be >= 0" , cfg .MaxConcurrentBatches )
189189 }
190190 if cfg .MaxFlushDelay < 0 {
191- return fmt .Errorf ("redis: AutoPipelineConfig .MaxFlushDelay=%s must be >= 0" , cfg .MaxFlushDelay )
191+ return fmt .Errorf ("redis: AutoPipelineOptions .MaxFlushDelay=%s must be >= 0" , cfg .MaxFlushDelay )
192192 }
193193 if cfg .NumShards < 0 {
194- return fmt .Errorf ("redis: AutoPipelineConfig .NumShards=%d must be >= 0" , cfg .NumShards )
194+ return fmt .Errorf ("redis: AutoPipelineOptions .NumShards=%d must be >= 0" , cfg .NumShards )
195195 }
196196 if cfg .AdaptiveDelay && cfg .MaxFlushDelay <= 0 {
197- return fmt .Errorf ("redis: AutoPipelineConfig .AdaptiveDelay requires MaxFlushDelay > 0 " +
197+ return fmt .Errorf ("redis: AutoPipelineOptions .AdaptiveDelay requires MaxFlushDelay > 0 " +
198198 "(adaptive delay scales MaxFlushDelay by queue fill; with no MaxFlushDelay it would " +
199199 "silently disable batch accumulation entirely)" )
200200 }
@@ -277,7 +277,7 @@ func putQueueSlice(slice []Cmder) {
277277// the pipeline on a normal connection (see Do).
278278// AutoPipeline / AsyncAutoPipeline return an error for an invalid config, so check it once:
279279//
280- // ap, err := client.AutoPipeline(nil )
280+ // ap, err := client.AutoPipeline()
281281// if err != nil {
282282// return err
283283// }
@@ -307,7 +307,7 @@ type AutoPipeliner struct {
307307 cmdable // Embed cmdable to get all Redis command methods
308308
309309 pipeliner cmdableClient
310- config * AutoPipelineConfig
310+ config * AutoPipelineOptions
311311 // blocking selects how the typed command surface (Set, Get, ...) behaves:
312312 // when true the command call itself blocks until the command has executed
313313 // (drop-in, synchronous shape); when false the call returns immediately and
@@ -423,14 +423,14 @@ func (s *apShard) stripe() *apStripe {
423423// and cache a new one. The caller supplies its cached-slot pointer, its
424424// closed flag (both guarded by the mutex), the explicit-config override, the
425425// fallback config, and a build closure (the cluster one wraps
426- // clusterAutoPipelineConfig and installs slot sharding).
426+ // clusterAutoPipelineOptions and installs slot sharding).
427427func getOrCreateAutoPipeliner (
428428 mu * sync.Mutex ,
429429 slot * * AutoPipeliner ,
430430 closed * bool ,
431- override * AutoPipelineConfig ,
432- fallback func () * AutoPipelineConfig ,
433- build func (* AutoPipelineConfig ) (* AutoPipeliner , error ),
431+ override * AutoPipelineOptions ,
432+ fallback func () * AutoPipelineOptions ,
433+ build func (* AutoPipelineOptions ) (* AutoPipeliner , error ),
434434) (* AutoPipeliner , error ) {
435435 mu .Lock ()
436436 defer mu .Unlock ()
@@ -457,13 +457,13 @@ func getOrCreateAutoPipeliner(
457457// Client/ClusterClient.AutoPipeline and AsyncAutoPipeline, which also install
458458// cluster slot-sharding. Constructing one directly would skip that wiring and
459459// give a *ClusterClient degraded (cross-node) batching.
460- func newAutoPipeliner (pipeliner cmdableClient , config * AutoPipelineConfig , blocking bool ) (* AutoPipeliner , error ) {
460+ func newAutoPipeliner (pipeliner cmdableClient , config * AutoPipelineOptions , blocking bool ) (* AutoPipeliner , error ) {
461461 if config == nil {
462- config = DefaultAutoPipelineConfig ()
462+ config = DefaultAutoPipelineOptions ()
463463 } else {
464464 // Copy so default-filling below doesn't mutate the caller's struct — the
465- // same *AutoPipelineConfig may be shared across clients (e.g. a reused
466- // Options.AutoPipelineConfig ), and callers may inspect it afterward.
465+ // same *AutoPipelineOptions may be shared across clients (e.g. a reused
466+ // Options.AutoPipelineOptions ), and callers may inspect it afterward.
467467 cfgCopy := * config
468468 config = & cfgCopy
469469 }
@@ -495,7 +495,7 @@ func newAutoPipeliner(pipeliner cmdableClient, config *AutoPipelineConfig, block
495495 // per-key order holds).
496496 if config .NumShards > 1 && ! config .Unordered && ! blocking && ! config .contentSharded {
497497 return nil , fmt .Errorf (
498- "redis: AutoPipelineConfig .NumShards=%d requires Unordered:true on the deferred (async) face " +
498+ "redis: AutoPipelineOptions .NumShards=%d requires Unordered:true on the deferred (async) face " +
499499 "(commands are distributed round-robin across shards, which flush concurrently and do not preserve submit order)" ,
500500 config .NumShards )
501501 }
@@ -667,14 +667,24 @@ func (ap *AutoPipeliner) PoolStats() *PoolStats { return ap.pipeliner.PoolStats(
667667// AutoPipeline delegates to the underlying client, which returns its cached
668668// autopipeliner (typically this same instance). Present to satisfy the
669669// UniversalClient surface.
670- func (ap * AutoPipeliner ) AutoPipeline (config * AutoPipelineConfig ) (* AutoPipeliner , error ) {
671- return ap .pipeliner .AutoPipeline (config )
670+ func (ap * AutoPipeliner ) AutoPipeline () (* AutoPipeliner , error ) {
671+ return ap .pipeliner .AutoPipeline ()
672+ }
673+
674+ // AutoPipelineWithOptions delegates to the underlying client.
675+ func (ap * AutoPipeliner ) AutoPipelineWithOptions (config * AutoPipelineOptions ) (* AutoPipeliner , error ) {
676+ return ap .pipeliner .AutoPipelineWithOptions (config )
672677}
673678
674679// AsyncAutoPipeline delegates to the underlying client. Present to satisfy the
675680// UniversalClient surface.
676- func (ap * AutoPipeliner ) AsyncAutoPipeline (config * AutoPipelineConfig ) (* AutoPipeliner , error ) {
677- return ap .pipeliner .AsyncAutoPipeline (config )
681+ func (ap * AutoPipeliner ) AsyncAutoPipeline () (* AutoPipeliner , error ) {
682+ return ap .pipeliner .AsyncAutoPipeline ()
683+ }
684+
685+ // AsyncAutoPipelineWithOptions delegates to the underlying client.
686+ func (ap * AutoPipeliner ) AsyncAutoPipelineWithOptions (config * AutoPipelineOptions ) (* AutoPipeliner , error ) {
687+ return ap .pipeliner .AsyncAutoPipelineWithOptions (config )
678688}
679689
680690// validate AutoPipeliner implements UniversalClient (drop-in for the real
@@ -879,7 +889,7 @@ func (s *apShard) wake() {
879889func (ap * AutoPipeliner ) IsBlocking () bool { return ap .blocking }
880890
881891// Config returns a copy of the effective configuration (defaults filled in).
882- func (ap * AutoPipeliner ) Config () AutoPipelineConfig { return * ap .config }
892+ func (ap * AutoPipeliner ) Config () AutoPipelineOptions { return * ap .config }
883893
884894// IsClosed reports whether the AutoPipeliner has been closed, either by an
885895// explicit Close or by closing the owning client. A closed AutoPipeliner
0 commit comments