func (p *DemoServiceClient) recvHello() (value string, err error) { iprot := p.InputProtocol if iprot == nil { iprot = p.ProtocolFactory.GetProtocol(p.Transport) p.InputProtocol = iprot } method, mTypeId, seqId, err := iprot.ReadMessageBegin() if err != nil { return } if method != "Hello" { err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Hello failed: wrong method name") return } if p.SeqId != seqId { err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Hello failed: out of sequence response") return } if mTypeId == thrift.EXCEPTION { error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") var error1 error error1, err = error0.Read(iprot) if err != nil { return } if err = iprot.ReadMessageEnd(); err != nil { return } err = error1 return } if mTypeId != thrift.REPLY { err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Hello failed: invalid message type") return } result := DemoServiceHelloResult{} if err = result.Read(iprot); err != nil { return } if err = iprot.ReadMessageEnd(); err != nil { return } value = result.GetSuccess() return }
func (p *demoServiceProcessorHello) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := DemoServiceHelloArgs{} if err = args.Read(iprot); err != nil { iprot.ReadMessageEnd() x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) oprot.WriteMessageBegin("Hello", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush() return false, err } iprot.ReadMessageEnd() result := DemoServiceHelloResult{} var retval string var err2 error if retval, err2 = p.handler.Hello(args.Name); err2 != nil { x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Hello: "+err2.Error()) oprot.WriteMessageBegin("Hello", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush() return true, err2 } else { result.Success = &retval } if err2 = oprot.WriteMessageBegin("Hello", 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.Flush(); err == nil && err2 != nil { err = err2 } if err != nil { return } return true, err }
func (p *DemoServiceProcessor) 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 }