本文整理汇总了Golang中github.com/apache/thrift/lib/go/thrift.TProtocol.ReadMessageBegin方法的典型用法代码示例。如果您正苦于以下问题:Golang TProtocol.ReadMessageBegin方法的具体用法?Golang TProtocol.ReadMessageBegin怎么用?Golang TProtocol.ReadMessageBegin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/apache/thrift/lib/go/thrift.TProtocol
的用法示例。
在下文中一共展示了TProtocol.ReadMessageBegin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handle
// Mostly borrowed from generated thrift code `Process` method, but with timing added.
func (p ThriftOverHTTPHandler) handle(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
name, _, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return false, err
}
if processor, ok := p.GetProcessorFunction(name); ok {
start := time.Now()
success, err = processor.Process(seqId, iprot, oprot)
if p.stats != nil {
p.stats.TimeSince(name, start)
}
return
}
iprot.Skip(thrift.STRUCT)
iprot.ReadMessageEnd()
e := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
e.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush()
return false, e
}
示例2: Process
// Mostly borrowed from generated thrift code `Process` method, but with timing added.
func (p LoggedProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
name, _, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return false, err
}
if processor, ok := p.GetProcessorFunction(name); ok {
if p.debug {
log.Println("[rpc]", name)
}
start := time.Now()
success, err = processor.Process(seqId, iprot, oprot)
if p.stats != nil {
if err != nil {
if p.debug {
log.Println("[rpc]", name, err)
}
p.stats.Inc("rpc.error." + name)
}
dur := time.Now().Sub(start)
p.stats.Time("rpc.timing._all_", dur)
p.stats.Time("rpc.timing."+name, dur)
}
return success, err
}
iprot.Skip(thrift.STRUCT)
iprot.ReadMessageEnd()
e := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
if p.debug {
log.Println("[rpc] unknown function:", name)
}
if p.stats != nil {
p.stats.Inc("rpc.error.unknown_function." + name)
}
oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
e.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush()
return true, e
}
示例3: Process
func (p *AccountProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
name, _, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return false, err
}
if processor, ok := p.GetProcessorFunction(name); ok {
return processor.Process(seqId, iprot, oprot)
}
iprot.Skip(thrift.STRUCT)
iprot.ReadMessageEnd()
x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
x3.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush()
return false, x3
}