本文整理汇总了Golang中tumblr/encoding/thrift.TProtocol类的典型用法代码示例。如果您正苦于以下问题:Golang TProtocol类的具体用法?Golang TProtocol怎么用?Golang TProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TProtocol类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReadField2
func (p *LogEntry) ReadField2(iprot thrift.TProtocol) (err thrift.TProtocolException) {
v2, err3 := iprot.ReadString()
if err3 != nil {
return thrift.NewTProtocolExceptionReadField(2, "message", p.ThriftName(), err3)
}
p.Message = v2
return err
}
示例2: ReadField0
func (p *LogResult) ReadField0(iprot thrift.TProtocol) (err thrift.TProtocolException) {
v24, err25 := iprot.ReadI32()
if err25 != nil {
return thrift.NewTProtocolExceptionReadField(0, "success", p.ThriftName(), err25)
}
p.Success = ResultCode(v24)
return err
}
示例3: ReadField1
func (p *LogEntry) ReadField1(iprot thrift.TProtocol) (err thrift.TProtocolException) {
v0, err1 := iprot.ReadString()
if err1 != nil {
return thrift.NewTProtocolExceptionReadField(1, "category", p.ThriftName(), err1)
}
p.Category = v0
return err
}
示例4: WriteField1
func (p *LogArgs) WriteField1(oprot thrift.TProtocol) (err thrift.TProtocolException) {
if p.Messages != nil {
err = oprot.WriteFieldBegin("messages", thrift.LIST, 1)
if err != nil {
return thrift.NewTProtocolExceptionWriteField(1, "messages", p.ThriftName(), err)
}
err = oprot.WriteListBegin(thrift.STRUCT, p.Messages.Len())
if err != nil {
return thrift.NewTProtocolExceptionWriteField(-1, "", "list", err)
}
for Iter22 := range p.Messages.Iter() {
Iter23 := Iter22.(*LogEntry)
err = Iter23.Write(oprot)
if err != nil {
return thrift.NewTProtocolExceptionWriteStruct("LogEntry", err)
}
}
err = oprot.WriteListEnd()
if err != nil {
return thrift.NewTProtocolExceptionWriteField(-1, "", "list", err)
}
err = oprot.WriteFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionWriteField(1, "messages", p.ThriftName(), err)
}
}
return err
}
示例5: ReadField1
func (p *LogArgs) ReadField1(iprot thrift.TProtocol) (err thrift.TProtocolException) {
_etype16, _size13, err := iprot.ReadListBegin()
if err != nil {
return thrift.NewTProtocolExceptionReadField(-1, "p.Messages", "", err)
}
p.Messages = thrift.NewTList(_etype16, _size13)
for _i17 := 0; _i17 < _size13; _i17++ {
_elem18 := NewLogEntry()
err21 := _elem18.Read(iprot)
if err21 != nil {
return thrift.NewTProtocolExceptionReadStruct("_elem18LogEntry", err21)
}
p.Messages.Push(_elem18)
}
err = iprot.ReadListEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadField(-1, "", "list", err)
}
return err
}
示例6: WriteField2
func (p *LogEntry) WriteField2(oprot thrift.TProtocol) (err thrift.TProtocolException) {
err = oprot.WriteFieldBegin("message", thrift.STRING, 2)
if err != nil {
return thrift.NewTProtocolExceptionWriteField(2, "message", p.ThriftName(), err)
}
err = oprot.WriteString(string(p.Message))
if err != nil {
return thrift.NewTProtocolExceptionWriteField(2, "message", p.ThriftName(), err)
}
err = oprot.WriteFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionWriteField(2, "message", p.ThriftName(), err)
}
return err
}
示例7: WriteField1
func (p *LogEntry) WriteField1(oprot thrift.TProtocol) (err thrift.TProtocolException) {
err = oprot.WriteFieldBegin("category", thrift.STRING, 1)
if err != nil {
return thrift.NewTProtocolExceptionWriteField(1, "category", p.ThriftName(), err)
}
err = oprot.WriteString(string(p.Category))
if err != nil {
return thrift.NewTProtocolExceptionWriteField(1, "category", p.ThriftName(), err)
}
err = oprot.WriteFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionWriteField(1, "category", p.ThriftName(), err)
}
return err
}
示例8: WriteField0
func (p *LogResult) WriteField0(oprot thrift.TProtocol) (err thrift.TProtocolException) {
err = oprot.WriteFieldBegin("success", thrift.I32, 0)
if err != nil {
return thrift.NewTProtocolExceptionWriteField(0, "success", p.ThriftName(), err)
}
err = oprot.WriteI32(int32(p.Success))
if err != nil {
return thrift.NewTProtocolExceptionWriteField(0, "success", p.ThriftName(), err)
}
err = oprot.WriteFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionWriteField(0, "success", p.ThriftName(), err)
}
return err
}
示例9: Write
func (p *LogArgs) Write(oprot thrift.TProtocol) (err thrift.TProtocolException) {
err = oprot.WriteStructBegin("Log_args")
if err != nil {
return thrift.NewTProtocolExceptionWriteStruct(p.ThriftName(), err)
}
err = p.WriteField1(oprot)
if err != nil {
return err
}
err = oprot.WriteFieldStop()
if err != nil {
return thrift.NewTProtocolExceptionWriteField(-1, "STOP", p.ThriftName(), err)
}
err = oprot.WriteStructEnd()
if err != nil {
return thrift.NewTProtocolExceptionWriteStruct(p.ThriftName(), err)
}
return err
}
示例10: Read
func (p *LogEntry) Read(iprot thrift.TProtocol) (err thrift.TProtocolException) {
_, err = iprot.ReadStructBegin()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
for {
fieldName, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if fieldId < 0 {
fieldId = int16(p.FieldIdFromFieldName(fieldName))
} else if fieldName == "" {
fieldName = p.FieldNameFromFieldId(int(fieldId))
}
if fieldTypeId == thrift.GENERIC {
fieldTypeId = p.FieldFromFieldId(int(fieldId)).TypeId()
}
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
if fieldTypeId == thrift.STOP {
break
}
if fieldId == 1 || fieldName == "category" {
if fieldTypeId == thrift.STRING {
err = p.ReadField1(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else if fieldTypeId == thrift.VOID {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else {
err = p.ReadField1(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
} else if fieldId == 2 || fieldName == "message" {
if fieldTypeId == thrift.STRING {
err = p.ReadField2(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else if fieldTypeId == thrift.VOID {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else {
err = p.ReadField2(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
} else {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
err = iprot.ReadFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
err = iprot.ReadStructEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
return err
}
示例11: Read
func (p *LogResult) Read(iprot thrift.TProtocol) (err thrift.TProtocolException) {
_, err = iprot.ReadStructBegin()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
for {
fieldName, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if fieldId < 0 {
fieldId = int16(p.FieldIdFromFieldName(fieldName))
} else if fieldName == "" {
fieldName = p.FieldNameFromFieldId(int(fieldId))
}
if fieldTypeId == thrift.GENERIC {
fieldTypeId = p.FieldFromFieldId(int(fieldId)).TypeId()
}
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
if fieldTypeId == thrift.STOP {
break
}
if fieldId == 0 || fieldName == "success" {
if fieldTypeId == thrift.I32 {
err = p.ReadField0(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else if fieldTypeId == thrift.VOID {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else {
err = p.ReadField0(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
} else {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
err = iprot.ReadFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
err = iprot.ReadStructEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
return err
}
示例12: Process
func (p *scribeProcessorLog) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := NewLogArgs()
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("Log", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Transport().Flush()
return
}
iprot.ReadMessageEnd()
result := NewLogResult()
if result.Success, err = p.handler.Log(args.Messages); err != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Log: "+err.Error())
oprot.WriteMessageBegin("Log", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Transport().Flush()
return
}
if err2 := oprot.WriteMessageBegin("Log", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 := result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 := oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 := oprot.Transport().Flush(); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}