Flush sends any buffered bytes to the server as a stage="progress" chunk. Uses a background context so a cancelled parent ctx does not prevent the final chunk from being sent.
()
| 2102 | // Uses a background context so a cancelled parent ctx does not prevent the |
| 2103 | // final chunk from being sent. |
| 2104 | func (s *streamSink) Flush() { |
| 2105 | s.mu.Lock() |
| 2106 | if s.pending.Len() == 0 { |
| 2107 | s.lastFlush = time.Now() |
| 2108 | s.mu.Unlock() |
| 2109 | return |
| 2110 | } |
| 2111 | chunk := s.pending.String() |
| 2112 | s.pending.Reset() |
| 2113 | s.lastFlush = time.Now() |
| 2114 | s.mu.Unlock() |
| 2115 | |
| 2116 | ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| 2117 | defer cancel() |
| 2118 | if err := s.client.SendPatchOutput(ctx, s.patchRunID, "progress", chunk, ""); err != nil { |
| 2119 | logger.WithError(err).WithField("patch_run_id", logutil.Sanitize(s.patchRunID)).Debug("Failed to send patch progress chunk") |
| 2120 | } |
| 2121 | } |
| 2122 | |
| 2123 | // runStreamingPatchStep executes a command, streaming its stdout+stderr into |
| 2124 | // the provided sink. On context cancellation it sends SIGINT and allows |
no test coverage detected