MCPcopy
hub / github.com/PatchMon/PatchMon / Flush

Method Flush

agent-source-code/cmd/patchmon-agent/commands/serve.go:2104–2121  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

2102// Uses a background context so a cancelled parent ctx does not prevent the
2103// final chunk from being sent.
2104func (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

Callers 4

WriteMethod · 0.95
runStreamingPatchStepFunction · 0.80
runPatchFunction · 0.80
BuildScheduledReportFunction · 0.80

Calls 2

ResetMethod · 0.80
SendPatchOutputMethod · 0.80

Tested by

no test coverage detected