MCPcopy
hub / github.com/wavetermdev/waveterm / AdaptOutputChToStream

Function AdaptOutputChToStream

pkg/wshutil/wshrpcio.go:25–44  ·  view source on GitHub ↗
(outputCh chan []byte, output io.Writer)

Source from the content-addressed store, hash-verified

23}
24
25func AdaptOutputChToStream(outputCh chan []byte, output io.Writer) error {
26 drain := false
27 defer func() {
28 if drain {
29 utilfn.DrainChannelSafe(outputCh, "AdaptOutputChToStream")
30 }
31 }()
32 for msg := range outputCh {
33 if _, err := output.Write(msg); err != nil {
34 drain = true
35 return fmt.Errorf("error writing to output (AdaptOutputChToStream): %w", err)
36 }
37 // write trailing newline
38 if _, err := output.Write([]byte{'\n'}); err != nil {
39 drain = true
40 return fmt.Errorf("error writing trailing newline to output (AdaptOutputChToStream): %w", err)
41 }
42 }
43 return nil
44}
45
46func AdaptMsgChToPty(outputCh chan []byte, oscEsc string, output io.Writer) error {
47 if len(oscEsc) != 5 {

Callers 6

connectToJobManagerMethod · 0.92
handleNewListenerConnFunction · 0.92
SetupConnRpcClientFunction · 0.85
handleDomainSocketClientFunction · 0.85

Calls 2

DrainChannelSafeFunction · 0.92
WriteMethod · 0.65

Tested by

no test coverage detected