本文整理汇总了Golang中github.com/uber/tchannel/golang/typed.ReadBuffer类的典型用法代码示例。如果您正苦于以下问题:Golang ReadBuffer类的具体用法?Golang ReadBuffer怎么用?Golang ReadBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReadBuffer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: recvPeerFrameOfType
// recvPeerFrameOfType waits for a new frame of a given type from the peer, failing
// if the next frame received is not of that type
func (mex *messageExchange) recvPeerFrameOfType(msgType messageType) (*Frame, error) {
frame, err := mex.recvPeerFrame()
if err != nil {
return nil, err
}
switch frame.Header.messageType {
case msgType:
return frame, nil
case messageTypeError:
errMsg := errorMessage{
id: frame.Header.ID,
}
var rbuf typed.ReadBuffer
rbuf.Wrap(frame.SizedPayload())
if err := errMsg.read(&rbuf); err != nil {
return nil, err
}
return nil, errMsg.AsSystemError()
default:
// TODO(mmihic): Should be treated as a protocol error
mex.mexset.log.Warnf("Received unexpected message %d for %d",
int(frame.Header.messageType), frame.Header.ID)
return nil, errUnexpectedFrameType
}
}
示例2: read
func (m *callRes) read(r *typed.ReadBuffer) error {
m.ResponseCode = ResponseCode(r.ReadByte())
m.Tracing.read(r)
m.Headers = callHeaders{}
m.Headers.read(r)
return r.Err()
}
示例3: read
func (s *Span) read(r *typed.ReadBuffer) error {
s.traceID = r.ReadUint64()
s.parentID = r.ReadUint64()
s.spanID = r.ReadUint64()
s.flags = r.ReadSingleByte()
return r.Err()
}
示例4: read
func (ch transportHeaders) read(r *typed.ReadBuffer) {
nh := r.ReadSingleByte()
for i := 0; i < int(nh); i++ {
k := r.ReadLen8String()
v := r.ReadLen8String()
ch[TransportHeaderName(k)] = v
}
}
示例5: ReadIn
// ReadIn reads the frame from the given io.Reader
func (f *Frame) ReadIn(r io.Reader) error {
var rbuf typed.ReadBuffer
rbuf.Wrap(f.headerBuffer)
if _, err := rbuf.FillFrom(r, FrameHeaderSize); err != nil {
return err
}
if err := f.Header.read(&rbuf); err != nil {
return err
}
if f.Header.PayloadSize() > 0 {
if _, err := io.ReadFull(r, f.SizedPayload()); err != nil {
return err
}
}
return nil
}
示例6: read
func (fh *FrameHeader) read(r *typed.ReadBuffer) error {
fh.size = r.ReadUint16()
fh.messageType = messageType(r.ReadSingleByte())
fh.reserved1 = r.ReadSingleByte()
fh.ID = r.ReadUint32()
r.ReadBytes(len(fh.reserved))
return r.Err()
}