本文整理汇总了Golang中github.com/uber/tchannel-go/typed.ReadBuffer类的典型用法代码示例。如果您正苦于以下问题:Golang ReadBuffer类的具体用法?Golang ReadBuffer怎么用?Golang ReadBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReadBuffer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: read
func (s *Span) read(r *typed.ReadBuffer) error {
s.spanID = r.ReadUint64()
s.parentID = r.ReadUint64()
s.traceID = r.ReadUint64()
s.flags = r.ReadSingleByte()
return r.Err()
}
开发者ID:uber,项目名称:tchannel-go,代码行数:7,代码来源:tracing.go
示例2: read
func (m *callRes) read(r *typed.ReadBuffer) error {
m.ResponseCode = ResponseCode(r.ReadSingleByte())
m.Tracing.read(r)
m.Headers = transportHeaders{}
m.Headers.read(r)
return r.Err()
}
开发者ID:gosuper,项目名称:tchannel-go,代码行数:7,代码来源:messages.go
示例3: 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.
// If an error frame is returned, then the errorMessage is returned as the error.
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
default:
// TODO(mmihic): Should be treated as a protocol error
mex.mexset.log.Warnf("Received unexpected message %v, expected %v for %d",
frame.Header.messageType, msgType, frame.Header.ID)
return nil, errUnexpectedFrameType
}
}
开发者ID:dansimau,项目名称:ringpop-go,代码行数:32,代码来源:mex.go
示例4: 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.
// If an error frame is returned, then the errorMessage is returned as the error.
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:
// If we read an error frame, we can release it once we deserialize it.
defer mex.framePool.Release(frame)
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
default:
// TODO(mmihic): Should be treated as a protocol error
mex.mexset.log.WithFields(
LogField{"header", frame.Header},
LogField{"expectedType", msgType},
LogField{"expectedID", mex.msgID},
).Warn("Received unexpected frame.")
return nil, errUnexpectedFrameType
}
}
开发者ID:uber,项目名称:tchannel-go,代码行数:37,代码来源:mex.go
示例5: readHeaders
func readHeaders(rb *typed.ReadBuffer, form http.Header) {
numHeaders := rb.ReadUint16()
for i := 0; i < int(numHeaders); i++ {
k := rb.ReadLen16String()
v := rb.ReadLen16String()
form[k] = append(form[k], v)
}
}
开发者ID:gosuper,项目名称:tchannel-go,代码行数:8,代码来源:buf.go
示例6: 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
}
开发者ID:gosuper,项目名称:tchannel-go,代码行数:20,代码来源:frame.go
示例7: 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()
}
开发者ID:gosuper,项目名称:tchannel-go,代码行数:8,代码来源:frame.go
示例8: readVarintString
func readVarintString(rb *typed.ReadBuffer) string {
length := rb.ReadUvarint()
return rb.ReadString(int(length))
}
开发者ID:gosuper,项目名称:tchannel-go,代码行数:4,代码来源:buf.go
注:本文中的github.com/uber/tchannel-go/typed.ReadBuffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论