本文整理匯總了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
}