mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-05 08:06:58 +08:00
285 lines
7.4 KiB
Go
285 lines
7.4 KiB
Go
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
|
|
|
|
package testutils
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"github.com/apache/thrift/lib/go/thrift"
|
|
"time"
|
|
)
|
|
|
|
// (needed to ensure safety because of naive import list construction.)
|
|
var _ = thrift.ZERO
|
|
var _ = fmt.Printf
|
|
var _ = context.Background
|
|
var _ = time.Now
|
|
var _ = bytes.Equal
|
|
|
|
// Attributes:
|
|
// - A
|
|
// - B
|
|
type ThriftArgs_ struct {
|
|
A int32 `thrift:"a,1" db:"a" json:"a"`
|
|
B int32 `thrift:"b,2" db:"b" json:"b"`
|
|
}
|
|
|
|
func NewThriftArgs_() *ThriftArgs_ {
|
|
return &ThriftArgs_{}
|
|
}
|
|
|
|
func (p *ThriftArgs_) GetA() int32 {
|
|
return p.A
|
|
}
|
|
|
|
func (p *ThriftArgs_) GetB() int32 {
|
|
return p.B
|
|
}
|
|
func (p *ThriftArgs_) Read(ctx context.Context, iprot thrift.TProtocol) error {
|
|
if _, err := iprot.ReadStructBegin(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
|
|
}
|
|
|
|
for {
|
|
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
|
|
if err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
|
|
}
|
|
if fieldTypeId == thrift.STOP {
|
|
break
|
|
}
|
|
switch fieldId {
|
|
case 1:
|
|
if fieldTypeId == thrift.I32 {
|
|
if err := p.ReadField1(ctx, iprot); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
case 2:
|
|
if fieldTypeId == thrift.I32 {
|
|
if err := p.ReadField2(ctx, iprot); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
default:
|
|
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := iprot.ReadFieldEnd(ctx); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := iprot.ReadStructEnd(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftArgs_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
|
|
if v, err := iprot.ReadI32(ctx); err != nil {
|
|
return thrift.PrependError("error reading field 1: ", err)
|
|
} else {
|
|
p.A = v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftArgs_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
|
|
if v, err := iprot.ReadI32(ctx); err != nil {
|
|
return thrift.PrependError("error reading field 2: ", err)
|
|
} else {
|
|
p.B = v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftArgs_) Write(ctx context.Context, oprot thrift.TProtocol) error {
|
|
if err := oprot.WriteStructBegin(ctx, "ThriftArgs"); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
|
}
|
|
if p != nil {
|
|
if err := p.writeField1(ctx, oprot); err != nil {
|
|
return err
|
|
}
|
|
if err := p.writeField2(ctx, oprot); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := oprot.WriteFieldStop(ctx); err != nil {
|
|
return thrift.PrependError("write field stop error: ", err)
|
|
}
|
|
if err := oprot.WriteStructEnd(ctx); err != nil {
|
|
return thrift.PrependError("write struct stop error: ", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftArgs_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
|
|
if err := oprot.WriteFieldBegin(ctx, "a", thrift.I32, 1); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err)
|
|
}
|
|
if err := oprot.WriteI32(ctx, int32(p.A)); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err)
|
|
}
|
|
if err := oprot.WriteFieldEnd(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (p *ThriftArgs_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
|
|
if err := oprot.WriteFieldBegin(ctx, "b", thrift.I32, 2); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err)
|
|
}
|
|
if err := oprot.WriteI32(ctx, int32(p.B)); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err)
|
|
}
|
|
if err := oprot.WriteFieldEnd(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (p *ThriftArgs_) Equals(other *ThriftArgs_) bool {
|
|
if p == other {
|
|
return true
|
|
} else if p == nil || other == nil {
|
|
return false
|
|
}
|
|
if p.A != other.A {
|
|
return false
|
|
}
|
|
if p.B != other.B {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (p *ThriftArgs_) String() string {
|
|
if p == nil {
|
|
return "<nil>"
|
|
}
|
|
return fmt.Sprintf("ThriftArgs_(%+v)", *p)
|
|
}
|
|
|
|
// Attributes:
|
|
// - C
|
|
type ThriftReply struct {
|
|
C int32 `thrift:"c,1" db:"c" json:"c"`
|
|
}
|
|
|
|
func NewThriftReply() *ThriftReply {
|
|
return &ThriftReply{}
|
|
}
|
|
|
|
func (p *ThriftReply) GetC() int32 {
|
|
return p.C
|
|
}
|
|
func (p *ThriftReply) Read(ctx context.Context, iprot thrift.TProtocol) error {
|
|
if _, err := iprot.ReadStructBegin(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
|
|
}
|
|
|
|
for {
|
|
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
|
|
if err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
|
|
}
|
|
if fieldTypeId == thrift.STOP {
|
|
break
|
|
}
|
|
switch fieldId {
|
|
case 1:
|
|
if fieldTypeId == thrift.I32 {
|
|
if err := p.ReadField1(ctx, iprot); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
default:
|
|
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := iprot.ReadFieldEnd(ctx); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := iprot.ReadStructEnd(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftReply) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
|
|
if v, err := iprot.ReadI32(ctx); err != nil {
|
|
return thrift.PrependError("error reading field 1: ", err)
|
|
} else {
|
|
p.C = v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftReply) Write(ctx context.Context, oprot thrift.TProtocol) error {
|
|
if err := oprot.WriteStructBegin(ctx, "ThriftReply"); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
|
|
}
|
|
if p != nil {
|
|
if err := p.writeField1(ctx, oprot); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := oprot.WriteFieldStop(ctx); err != nil {
|
|
return thrift.PrependError("write field stop error: ", err)
|
|
}
|
|
if err := oprot.WriteStructEnd(ctx); err != nil {
|
|
return thrift.PrependError("write struct stop error: ", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *ThriftReply) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
|
|
if err := oprot.WriteFieldBegin(ctx, "c", thrift.I32, 1); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:c: ", p), err)
|
|
}
|
|
if err := oprot.WriteI32(ctx, int32(p.C)); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T.c (1) field write error: ", p), err)
|
|
}
|
|
if err := oprot.WriteFieldEnd(ctx); err != nil {
|
|
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:c: ", p), err)
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (p *ThriftReply) Equals(other *ThriftReply) bool {
|
|
if p == other {
|
|
return true
|
|
} else if p == nil || other == nil {
|
|
return false
|
|
}
|
|
if p.C != other.C {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (p *ThriftReply) String() string {
|
|
if p == nil {
|
|
return "<nil>"
|
|
}
|
|
return fmt.Sprintf("ThriftReply(%+v)", *p)
|
|
}
|