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

Method req2Byte

tars/tarsprotocol.go:156–175  ·  view source on GitHub ↗
(rsp *requestf.ResponsePacket)

Source from the content-addressed store, hash-verified

154}
155
156func (s *Protocol) req2Byte(rsp *requestf.ResponsePacket) []byte {
157 req := requestf.RequestPacket{}
158 req.IVersion = rsp.IVersion
159 req.IRequestId = rsp.IRequestId
160 req.IMessageType = rsp.IMessageType
161 req.CPacketType = rsp.CPacketType
162 req.Context = rsp.Context
163 req.Status = rsp.Status
164 req.SBuffer = rsp.SBuffer
165
166 os := codec.NewBuffer()
167 req.WriteTo(os)
168 bs := os.ToBytes()
169 sbuf := bytes.NewBuffer(nil)
170 sbuf.Write(make([]byte, 4))
171 sbuf.Write(bs)
172 length := sbuf.Len()
173 binary.BigEndian.PutUint32(sbuf.Bytes(), uint32(length))
174 return sbuf.Bytes()
175}
176
177func (s *Protocol) rsp2Byte(rsp *requestf.ResponsePacket) []byte {
178 if rsp.IVersion == basef.TUPVERSION {

Callers 1

rsp2ByteMethod · 0.95

Calls 5

WriteToMethod · 0.95
ToBytesMethod · 0.95
LenMethod · 0.95
NewBufferFunction · 0.92
WriteMethod · 0.65

Tested by

no test coverage detected