MCPcopy Index your code
hub / github.com/devspace-sh/devspace / SendData

Function SendData

helper/tunnel/server.go:55–88  ·  view source on GitHub ↗
(stream remote.Tunnel_InitTunnelServer, sessions <-chan *Session, closeChan chan struct{})

Source from the content-addressed store, hash-verified

53}
54
55func SendData(stream remote.Tunnel_InitTunnelServer, sessions <-chan *Session, closeChan chan struct{}) {
56 for {
57 select {
58 case <-closeChan:
59 return
60 case <-stream.Context().Done():
61 return
62 case session := <-sessions:
63 // read the bytes from the buffer
64 // but allow it to keep growing while we send the response
65 session.Lock()
66 bys := session.Buf.Len()
67 bytes := make([]byte, bys)
68 _, _ = session.Buf.Read(bytes)
69 resp := &remote.SocketDataResponse{
70 HasErr: false,
71 LogMessage: nil,
72 Data: bytes,
73 RequestId: session.ID.String(),
74 ShouldClose: !session.Open,
75 }
76 session.Unlock()
77
78 stderrlog.Debugf("sending %d bytes to client", len(bytes))
79 err := stream.Send(resp)
80 if err != nil {
81 stderrlog.Errorf("failed sending message to tunnel stream: %v", err)
82 close(closeChan)
83 return
84 }
85 stderrlog.Debugf("sent %d bytes to client", len(bytes))
86 }
87 }
88}
89
90func ReceiveData(stream remote.Tunnel_InitTunnelServer, closeChan chan struct{}) {
91 for {

Callers 1

InitTunnelMethod · 0.70

Calls 11

DebugfFunction · 0.92
ErrorfFunction · 0.92
closeFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
DoneMethod · 0.65
ContextMethod · 0.65
SendMethod · 0.65
LenMethod · 0.45
ReadMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected