enhance comment

This commit is contained in:
Max Kotliar
2026-05-12 16:00:01 +03:00
parent d3c830fbcf
commit 3d6d308b80

View File

@@ -327,7 +327,8 @@ func (c *client) runWorker() {
c.fq.MustWriteBlockIgnoreDisabledPQ(block)
return
case <-c.stopCh:
// c must be stopped. Wait for a while in the hope the block will be sent.
// c must be stopped. Wait up to 5 seconds for the in-flight request to complete.
// If it succeeds, drain the remaining in-memory queue before returning.
stopCtx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
@@ -336,12 +337,13 @@ func (c *client) runWorker() {
if !ok {
// Return unsent block to the queue.
c.fq.MustWriteBlockIgnoreDisabledPQ(block)
} else {
c.drainInMemoryQueue(stopCtx, block[:0])
}
case <-stopCtx.Done():
// Return unsent block to the queue.
c.fq.MustWriteBlockIgnoreDisabledPQ(block)
}
c.drainInMemoryQueue(stopCtx, block[:0])
return
}
}