Skip to content

Commit 28dd5d3

Browse files
committed
style(autopipeline): fix lint in full-duplex dispatch
Clears the three pre-existing staticcheck failures in the ordered full-duplex file (present before the teardown/recovery fix; that commit added none): - ST1008: reorder attempt() and session() return values so the error is the last argument -- (unacked, result, aerr) instead of (unacked, aerr, result). Pure reordering; the two call sites are updated to match. error and fdResult are distinct types, so any misorder fails to compile. - unused: //nolint:unused on fdInflight.peakLen, which is exercised only by the full-duplex backpressure tests (the repo lints with run.tests=false, so test-only usage is invisible to the unused check).
1 parent cf78539 commit 28dd5d3

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

autopipeline_fullduplex.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ func (f *fdInflight) pushBatch(reqs []fdReq) {
143143

144144
// peakLen returns the high-water mark of in-flight entries seen so far (test
145145
// observability for the backpressure bound).
146+
//
147+
//nolint:unused // used by the full-duplex backpressure tests; lint runs with tests:false.
146148
func (f *fdInflight) peakLen() int {
147149
f.mu.Lock()
148150
n := f.peak
@@ -377,7 +379,7 @@ func (fd *fdEngine) run() {
377379
fd.drainQueue(ErrClosed)
378380
return
379381
}
380-
unacked, aerr, result := fd.attempt(bg, carry)
382+
unacked, result, aerr := fd.attempt(bg, carry)
381383
switch result {
382384
case fdGraceful:
383385
return // Close: attempt drained written work; queue failed there.
@@ -422,23 +424,23 @@ func (fd *fdEngine) run() {
422424
// attempt acquires a connection, runs one full-duplex session (re-issuing carry
423425
// first), and releases the connection. Returns the unacked tail + error on
424426
// connection failure, or graceful=true on Close.
425-
func (fd *fdEngine) attempt(bg context.Context, carry []fdReq) (unacked []fdReq, aerr error, result fdResult) {
427+
func (fd *fdEngine) attempt(bg context.Context, carry []fdReq) (unacked []fdReq, result fdResult, aerr error) {
426428
cn, err := fd.pool.Get(bg)
427429
if err != nil {
428-
return carry, err, fdConnErr
430+
return carry, fdConnErr, err
429431
}
430432
if !cn.IsInited() {
431433
if e := fd.client.initConn(bg, cn); e != nil {
432434
fd.pool.Remove(bg, cn, e)
433-
return carry, e, fdConnErr
435+
return carry, fdConnErr, e
434436
}
435437
if !cn.TryAcquire() {
436438
fd.pool.Remove(bg, cn, errFDConnUnusable)
437-
return carry, errFDConnUnusable, fdConnErr
439+
return carry, fdConnErr, errFDConnUnusable
438440
}
439441
}
440442

441-
unacked, aerr, result = fd.session(bg, cn, carry)
443+
unacked, result, aerr = fd.session(bg, cn, carry)
442444

443445
// Clean ends (graceful / idle / recycle) leave the conn at a RESP boundary —
444446
// Put it back so the pool (and its hooks) own it again. ANY connection-error
@@ -452,12 +454,12 @@ func (fd *fdEngine) attempt(bg context.Context, carry []fdReq) (unacked []fdReq,
452454
} else {
453455
fd.pool.Put(bg, cn)
454456
}
455-
return unacked, aerr, result
457+
return unacked, result, aerr
456458
}
457459

458460
// session runs the writer (this goroutine) + reader (spawned) on one connection
459461
// until Close (graceful) or a connection error (returns the unacked tail).
460-
func (fd *fdEngine) session(bg context.Context, cn *pool.Conn, carry []fdReq) (unacked []fdReq, aerr error, result fdResult) {
462+
func (fd *fdEngine) session(bg context.Context, cn *pool.Conn, carry []fdReq) (unacked []fdReq, result fdResult, aerr error) {
461463
inflight := newFDInflight()
462464
fd.curInflight.Store(inflight) // test observability (peak in-flight)
463465
readerDone := make(chan struct{})
@@ -624,9 +626,9 @@ func (fd *fdEngine) session(bg context.Context, cn *pool.Conn, carry []fdReq) (u
624626
// error so attempt() removes the conn. run() exits on its next loop
625627
// (ctx is already done), so this does not retry.
626628
fd.failReqs(inflight.takeRemaining(), sharedErr)
627-
return nil, sharedErr, fdConnErr
629+
return nil, fdConnErr, sharedErr
628630
}
629-
return nil, nil, fdGraceful
631+
return nil, fdGraceful, nil
630632
case fdIdle, fdRecycle:
631633
// Clean return: no more pushes, reader drains remaining replies, then the
632634
// conn is at a RESP boundary and safe to Put back to the pool.
@@ -637,9 +639,9 @@ func (fd *fdEngine) session(bg context.Context, cn *pool.Conn, carry []fdReq) (u
637639
// unacked tail for replay and report the error so the conn is removed
638640
// instead of Put back poisoned. (Fixes the readerDone/clean-result
639641
// race where a protocol error would otherwise Put a bad conn.)
640-
return inflight.takeRemaining(), sharedErr, fdConnErr
642+
return inflight.takeRemaining(), fdConnErr, sharedErr
641643
}
642-
return nil, nil, result
644+
return nil, result, nil
643645
default: // fdConnErr
644646
// Stop the reader, wait for it to exit, THEN take the unacked tail — so
645647
// the reader (which advances every command it completes) and this
@@ -652,7 +654,7 @@ func (fd *fdEngine) session(bg context.Context, cn *pool.Conn, carry []fdReq) (u
652654
if sharedErr == nil {
653655
sharedErr = errFDReaderGone
654656
}
655-
return unacked, sharedErr, fdConnErr
657+
return unacked, fdConnErr, sharedErr
656658
}
657659
}
658660

0 commit comments

Comments
 (0)