MCPcopy
hub / github.com/TarsCloud/TarsGo / Invoke

Method Invoke

tars/protocol/push/server.go:59–76  ·  view source on GitHub ↗

Invoke process request and send response

(ctx context.Context, reqBytes []byte)

Source from the content-addressed store, hash-verified

57
58// Invoke process request and send response
59func (s *serverProtocol) Invoke(ctx context.Context, reqBytes []byte) []byte {
60 req := &requestf.RequestPacket{}
61 rsp := &requestf.ResponsePacket{}
62 is := codec.NewReader(reqBytes[4:])
63 if err := req.ReadFrom(is); err != nil {
64 rsp.IRet = 1
65 rsp.SResultDesc = "decode request package error"
66 } else {
67 rsp.IVersion = req.IVersion
68 rsp.CPacketType = req.CPacketType
69 rsp.IRequestId = req.IRequestId
70 if req.SFuncName != "tars_ping" {
71 rspData := s.s.OnConnect(ctx, tools.Int8ToByte(req.SBuffer))
72 rsp.SBuffer = tools.ByteToInt8(rspData)
73 }
74 }
75 return response2Bytes(rsp)
76}
77
78func response2Bytes(rsp *requestf.ResponsePacket) []byte {
79 os := codec.NewBuffer()

Callers

nothing calls this directly

Calls 6

ReadFromMethod · 0.95
NewReaderFunction · 0.92
Int8ToByteFunction · 0.92
ByteToInt8Function · 0.92
response2BytesFunction · 0.85
OnConnectMethod · 0.65

Tested by

no test coverage detected