fishy commented on PR #2977: URL: https://github.com/apache/thrift/pull/2977#issuecomment-2116452758
<details> <summary>deprecated.thrift</summary> ```thrift namespace * deprecated enum Foo { Bar (deprecated = "dep-1") } (deprecated = "dep-2") struct depstruct { 1: string one (deprecated = "dep-3") } (deprecated = "dep-4") union depunion { 1: string one (deprecated = "dep-5") } (deprecated = "dep-6") exception depexcept { 1: string one (deprecated = "dep-7") } (deprecated = "dep-8") service inner { void Blibb() (deprecated = "dep-9") } (deprecated = "dep-10") service outer extends inner { void Plopp() (deprecated = "dep-11") } (deprecated = "dep-12") ``` </details> <details> <summary>gen-go/deprecated/deprecated.go</summary> ```go // Code generated by Thrift Compiler (0.21.0). DO NOT EDIT. package deprecated import ( "bytes" "context" "database/sql/driver" "errors" "fmt" "log/slog" "time" thrift "github.com/apache/thrift/lib/go/thrift" "strings" "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = bytes.Equal var _ = context.Background var _ = errors.New var _ = fmt.Printf var _ = slog.Log var _ = time.Now var _ = thrift.ZERO // (needed by validator.) var _ = strings.Contains var _ = regexp.MatchString // Deprecated: dep-2 type Foo int64 const ( // Deprecated: dep-1 Foo_Bar Foo = 0 ) func (p Foo) String() string { switch p { case Foo_Bar: return "Bar" } return "<UNSET>" } // Deprecated: dep-2 func FooFromString(s string) (Foo, error) { switch s { case "Bar": return Foo_Bar, nil } return Foo(0), fmt.Errorf("not a valid Foo string") } // Deprecated: dep-2 func FooPtr(v Foo) *Foo { return &v } func (p Foo) MarshalText() ([]byte, error) { return []byte(p.String()), nil } func (p *Foo) UnmarshalText(text []byte) error { q, err := FooFromString(string(text)) if err != nil { return err } *p = q return nil } func (p *Foo) Scan(value interface{}) error { v, ok := value.(int64) if !ok { return errors.New("Scan value is not int64") } *p = Foo(v) return nil } func (p *Foo) Value() (driver.Value, error) { if p == nil { return nil, nil } return int64(*p), nil } // Attributes: // - One // // Deprecated: dep-4 type Depstruct struct { // Deprecated: dep-3 One string `thrift:"one,1" db:"one" json:"one"` } // Deprecated: dep-4 func NewDepstruct() *Depstruct { return &Depstruct{} } // Deprecated: dep-3 func (p *Depstruct) GetOne() string { return p.One } func (p *Depstruct) 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.STRING { 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 *Depstruct) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.One = v } return nil } func (p *Depstruct) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "depstruct"); 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 *Depstruct) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if err := oprot.WriteFieldBegin(ctx, "one", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:one: ", p), err) } if err := oprot.WriteString(ctx, string(p.One)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.one (1) field write error: ", p), err) } if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:one: ", p), err) } return err } func (p *Depstruct) Equals(other *Depstruct) bool { if p == other { return true } else if p == nil || other == nil { return false } if p.One != other.One { return false } return true } func (p *Depstruct) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("Depstruct(%+v)", *p) } func (p *Depstruct) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.Depstruct", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*Depstruct)(nil) func (p *Depstruct) Validate() error { return nil } // Attributes: // - One // // Deprecated: dep-6 type Depunion struct { // Deprecated: dep-5 One *string `thrift:"one,1" db:"one" json:"one,omitempty"` } // Deprecated: dep-6 func NewDepunion() *Depunion { return &Depunion{} } // Deprecated: dep-5 var Depunion_One_DEFAULT string // Deprecated: dep-5 func (p *Depunion) GetOne() string { if !p.IsSetOne() { return Depunion_One_DEFAULT } return *p.One } func (p *Depunion) CountSetFieldsDepunion() int { count := 0 if (p.IsSetOne()) { count++ } return count } // Deprecated: dep-5 func (p *Depunion) IsSetOne() bool { return p.One != nil } func (p *Depunion) 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.STRING { 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 *Depunion) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.One = &v } return nil } func (p *Depunion) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsDepunion(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set)", p, c) } if err := oprot.WriteStructBegin(ctx, "depunion"); 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 *Depunion) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetOne() { if err := oprot.WriteFieldBegin(ctx, "one", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:one: ", p), err) } if err := oprot.WriteString(ctx, string(*p.One)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.one (1) field write error: ", p), err) } if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:one: ", p), err) } } return err } func (p *Depunion) Equals(other *Depunion) bool { if p == other { return true } else if p == nil || other == nil { return false } if p.One != other.One { if p.One == nil || other.One == nil { return false } if (*p.One) != (*other.One) { return false } } return true } func (p *Depunion) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("Depunion(%+v)", *p) } func (p *Depunion) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.Depunion", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*Depunion)(nil) func (p *Depunion) Validate() error { return nil } // Attributes: // - One // // Deprecated: dep-8 type Depexcept struct { // Deprecated: dep-7 One string `thrift:"one,1" db:"one" json:"one"` } // Deprecated: dep-8 func NewDepexcept() *Depexcept { return &Depexcept{} } // Deprecated: dep-7 func (p *Depexcept) GetOne() string { return p.One } func (p *Depexcept) 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.STRING { 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 *Depexcept) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.One = v } return nil } func (p *Depexcept) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "depexcept"); 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 *Depexcept) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if err := oprot.WriteFieldBegin(ctx, "one", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:one: ", p), err) } if err := oprot.WriteString(ctx, string(p.One)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.one (1) field write error: ", p), err) } if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:one: ", p), err) } return err } func (p *Depexcept) Equals(other *Depexcept) bool { if p == other { return true } else if p == nil || other == nil { return false } if p.One != other.One { return false } return true } func (p *Depexcept) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("Depexcept(%+v)", *p) } func (p *Depexcept) Error() string { return p.String() } func (Depexcept) TExceptionType() thrift.TExceptionType { return thrift.TExceptionTypeCompiled } var _ thrift.TException = (*Depexcept)(nil) func (p *Depexcept) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.Depexcept", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*Depexcept)(nil) func (p *Depexcept) Validate() error { return nil } // Deprecated: dep-10 type Inner interface { // Deprecated: dep-9 Blibb(ctx context.Context) (_err error) } // Deprecated: dep-10 type InnerClient struct { c thrift.TClient meta thrift.ResponseMeta } // Deprecated: dep-10 func NewInnerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *InnerClient { return &InnerClient{ c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), } } // Deprecated: dep-10 func NewInnerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *InnerClient { return &InnerClient{ c: thrift.NewTStandardClient(iprot, oprot), } } // Deprecated: dep-10 func NewInnerClient(c thrift.TClient) *InnerClient { return &InnerClient{ c: c, } } func (p *InnerClient) Client_() thrift.TClient { return p.c } func (p *InnerClient) LastResponseMeta_() thrift.ResponseMeta { return p.meta } func (p *InnerClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { p.meta = meta } // Deprecated: dep-9 func (p *InnerClient) Blibb(ctx context.Context) (_err error) { var _args0 InnerBlibbArgs var _result2 InnerBlibbResult var _meta1 thrift.ResponseMeta _meta1, _err = p.Client_().Call(ctx, "Blibb", &_args0, &_result2) p.SetLastResponseMeta_(_meta1) if _err != nil { return } return nil } // Deprecated: dep-10 type InnerProcessor struct { processorMap map[string]thrift.TProcessorFunction handler Inner } func (p *InnerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { p.processorMap[key] = processor } func (p *InnerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { processor, ok = p.processorMap[key] return processor, ok } func (p *InnerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { return p.processorMap } // Deprecated: dep-10 func NewInnerProcessor(handler Inner) *InnerProcessor { self3 := &InnerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} self3.processorMap["Blibb"] = &innerProcessorBlibb{handler:handler} return self3 } func (p *InnerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { name, _, seqId, err2 := iprot.ReadMessageBegin(ctx) if err2 != nil { return false, thrift.WrapTException(err2) } if processor, ok := p.GetProcessorFunction(name); ok { return processor.Process(ctx, seqId, iprot, oprot) } iprot.Skip(ctx, thrift.STRUCT) iprot.ReadMessageEnd(ctx) x4 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) x4.Write(ctx, oprot) oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) return false, x4 } type innerProcessorBlibb struct { handler Inner } func (p *innerProcessorBlibb) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { var _write_err5 error args := InnerBlibbArgs{} if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) oprot.WriteMessageBegin(ctx, "Blibb", thrift.EXCEPTION, seqId) x.Write(ctx, oprot) oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) return false, thrift.WrapTException(err2) } iprot.ReadMessageEnd(ctx) tickerCancel := func() {} // Start a goroutine to do server side connectivity check. if thrift.ServerConnectivityCheckInterval > 0 { var cancel context.CancelCauseFunc ctx, cancel = context.WithCancelCause(ctx) defer cancel(nil) var tickerCtx context.Context tickerCtx, tickerCancel = context.WithCancel(context.Background()) defer tickerCancel() go func(ctx context.Context, cancel context.CancelCauseFunc) { ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: if !iprot.Transport().IsOpen() { cancel(thrift.ErrAbandonRequest) return } } } }(tickerCtx, cancel) } result := InnerBlibbResult{} if err2 := p.handler.Blibb(ctx); err2 != nil { tickerCancel() err = thrift.WrapTException(err2) if errors.Is(err2, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err2) } if errors.Is(err2, context.Canceled) { if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err) } } _exc6 := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Blibb: " + err2.Error()) if err2 := oprot.WriteMessageBegin(ctx, "Blibb", thrift.EXCEPTION, seqId); err2 != nil { _write_err5 = thrift.WrapTException(err2) } if err2 := _exc6.Write(ctx, oprot); _write_err5 == nil && err2 != nil { _write_err5 = thrift.WrapTException(err2) } if err2 := oprot.WriteMessageEnd(ctx); _write_err5 == nil && err2 != nil { _write_err5 = thrift.WrapTException(err2) } if err2 := oprot.Flush(ctx); _write_err5 == nil && err2 != nil { _write_err5 = thrift.WrapTException(err2) } if _write_err5 != nil { return false, thrift.WrapTException(_write_err5) } return true, err } tickerCancel() if err2 := oprot.WriteMessageBegin(ctx, "Blibb", thrift.REPLY, seqId); err2 != nil { _write_err5 = thrift.WrapTException(err2) } if err2 := result.Write(ctx, oprot); _write_err5 == nil && err2 != nil { _write_err5 = thrift.WrapTException(err2) } if err2 := oprot.WriteMessageEnd(ctx); _write_err5 == nil && err2 != nil { _write_err5 = thrift.WrapTException(err2) } if err2 := oprot.Flush(ctx); _write_err5 == nil && err2 != nil { _write_err5 = thrift.WrapTException(err2) } if _write_err5 != nil { return false, thrift.WrapTException(_write_err5) } return true, err } // HELPER FUNCTIONS AND STRUCTURES type InnerBlibbArgs struct { } func NewInnerBlibbArgs() *InnerBlibbArgs { return &InnerBlibbArgs{} } func (p *InnerBlibbArgs) 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 } 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 *InnerBlibbArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "Blibb_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } 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 *InnerBlibbArgs) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("InnerBlibbArgs(%+v)", *p) } func (p *InnerBlibbArgs) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.InnerBlibbArgs", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*InnerBlibbArgs)(nil) type InnerBlibbResult struct { } func NewInnerBlibbResult() *InnerBlibbResult { return &InnerBlibbResult{} } func (p *InnerBlibbResult) 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 } 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 *InnerBlibbResult) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "Blibb_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } 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 *InnerBlibbResult) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("InnerBlibbResult(%+v)", *p) } func (p *InnerBlibbResult) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.InnerBlibbResult", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*InnerBlibbResult)(nil) // Deprecated: dep-12 type Outer interface { Inner // Deprecated: dep-11 Plopp(ctx context.Context) (_err error) } // Deprecated: dep-12 type OuterClient struct { *InnerClient } // Deprecated: dep-12 func NewOuterClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *OuterClient { return &OuterClient{InnerClient: NewInnerClientFactory(t, f)}} // Deprecated: dep-12 func NewOuterClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *OuterClient { return &OuterClient{InnerClient: NewInnerClientProtocol(t, iprot, oprot)} } // Deprecated: dep-12 func NewOuterClient(c thrift.TClient) *OuterClient { return &OuterClient{ InnerClient: NewInnerClient(c), } } // Deprecated: dep-11 func (p *OuterClient) Plopp(ctx context.Context) (_err error) { var _args7 OuterPloppArgs var _result9 OuterPloppResult var _meta8 thrift.ResponseMeta _meta8, _err = p.Client_().Call(ctx, "Plopp", &_args7, &_result9) p.SetLastResponseMeta_(_meta8) if _err != nil { return } return nil } type OuterProcessor struct { *InnerProcessor } func NewOuterProcessor(handler Outer) *OuterProcessor { self10 := &OuterProcessor{NewInnerProcessor(handler)} self10.AddToProcessorMap("Plopp", &outerProcessorPlopp{handler:handler}) return self10 } type outerProcessorPlopp struct { handler Outer } func (p *outerProcessorPlopp) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { var _write_err11 error args := OuterPloppArgs{} if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) oprot.WriteMessageBegin(ctx, "Plopp", thrift.EXCEPTION, seqId) x.Write(ctx, oprot) oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) return false, thrift.WrapTException(err2) } iprot.ReadMessageEnd(ctx) tickerCancel := func() {} // Start a goroutine to do server side connectivity check. if thrift.ServerConnectivityCheckInterval > 0 { var cancel context.CancelCauseFunc ctx, cancel = context.WithCancelCause(ctx) defer cancel(nil) var tickerCtx context.Context tickerCtx, tickerCancel = context.WithCancel(context.Background()) defer tickerCancel() go func(ctx context.Context, cancel context.CancelCauseFunc) { ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: if !iprot.Transport().IsOpen() { cancel(thrift.ErrAbandonRequest) return } } } }(tickerCtx, cancel) } result := OuterPloppResult{} if err2 := p.handler.Plopp(ctx); err2 != nil { tickerCancel() err = thrift.WrapTException(err2) if errors.Is(err2, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err2) } if errors.Is(err2, context.Canceled) { if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err) } } _exc12 := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Plopp: " + err2.Error()) if err2 := oprot.WriteMessageBegin(ctx, "Plopp", thrift.EXCEPTION, seqId); err2 != nil { _write_err11 = thrift.WrapTException(err2) } if err2 := _exc12.Write(ctx, oprot); _write_err11 == nil && err2 != nil { _write_err11 = thrift.WrapTException(err2) } if err2 := oprot.WriteMessageEnd(ctx); _write_err11 == nil && err2 != nil { _write_err11 = thrift.WrapTException(err2) } if err2 := oprot.Flush(ctx); _write_err11 == nil && err2 != nil { _write_err11 = thrift.WrapTException(err2) } if _write_err11 != nil { return false, thrift.WrapTException(_write_err11) } return true, err } tickerCancel() if err2 := oprot.WriteMessageBegin(ctx, "Plopp", thrift.REPLY, seqId); err2 != nil { _write_err11 = thrift.WrapTException(err2) } if err2 := result.Write(ctx, oprot); _write_err11 == nil && err2 != nil { _write_err11 = thrift.WrapTException(err2) } if err2 := oprot.WriteMessageEnd(ctx); _write_err11 == nil && err2 != nil { _write_err11 = thrift.WrapTException(err2) } if err2 := oprot.Flush(ctx); _write_err11 == nil && err2 != nil { _write_err11 = thrift.WrapTException(err2) } if _write_err11 != nil { return false, thrift.WrapTException(_write_err11) } return true, err } // HELPER FUNCTIONS AND STRUCTURES type OuterPloppArgs struct { } func NewOuterPloppArgs() *OuterPloppArgs { return &OuterPloppArgs{} } func (p *OuterPloppArgs) 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 } 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 *OuterPloppArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "Plopp_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } 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 *OuterPloppArgs) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("OuterPloppArgs(%+v)", *p) } func (p *OuterPloppArgs) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.OuterPloppArgs", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*OuterPloppArgs)(nil) type OuterPloppResult struct { } func NewOuterPloppResult() *OuterPloppResult { return &OuterPloppResult{} } func (p *OuterPloppResult) 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 } 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 *OuterPloppResult) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "Plopp_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } 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 *OuterPloppResult) String() string { if p == nil { return "<nil>" } return fmt.Sprintf("OuterPloppResult(%+v)", *p) } func (p *OuterPloppResult) LogValue() slog.Value { if p == nil { return slog.AnyValue(nil) } v := thrift.SlogTStructWrapper{ Type: "*deprecated.OuterPloppResult", Value: p, } return slog.AnyValue(v) } var _ slog.LogValuer = (*OuterPloppResult)(nil) ``` </details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@thrift.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org