feat 修改pusher options返回类型
All checks were successful
Build image / build (push) Successful in 1m27s

This commit is contained in:
timerzz 2024-05-21 14:01:28 +08:00
parent 56f3155d99
commit e099838d65
8 changed files with 616 additions and 121 deletions

View File

@ -18,9 +18,17 @@ func NewGetPusherOptionsService(ctx context.Context) *GetPusherOptionsService {
func (s *GetPusherOptionsService) Run() (resp *push.GetPusherOptionsResponse, err error) { func (s *GetPusherOptionsService) Run() (resp *push.GetPusherOptionsResponse, err error) {
// Finish your business logic. // Finish your business logic.
resp = new(push.GetPusherOptionsResponse) resp = new(push.GetPusherOptionsResponse)
resp.Options = map[config.PusherConfigType][]*config.FormItem{ resp.Options = []*config.PusherOption{
config.PusherConfigType_AnPush: toFormItems(config.AnPush{}), {
config.PusherConfigType_Email: toFormItems(config.EmailPush{}), Title: "AnPush",
Type: config.PusherConfigType_AnPush,
FormItems: toFormItems(config.AnPush{}),
},
{
Title: "邮箱",
Type: config.PusherConfigType_Email,
FormItems: toFormItems(config.EmailPush{}),
},
} }
return return
} }

View File

@ -12,6 +12,12 @@ struct PusherConfig {
6: required string option 6: required string option
} }
struct PusherOption {
1: string title
2: PusherConfigType type
3: list<FormItem> formItems
}
struct FormItem { struct FormItem {
1: string param 1: string param
2: string type 2: string type

View File

@ -25,7 +25,7 @@ struct ListPusherResponse {
} }
struct GetPusherOptionsResponse { struct GetPusherOptionsResponse {
1: map<config.PusherConfigType,list<config.FormItem>> options 1: list<config.PusherOption> options
} }
service PushService{ service PushService{

View File

@ -526,6 +526,313 @@ func (p *PusherConfig) Field6DeepEqual(src string) bool {
return true return true
} }
type PusherOption struct {
Title string `thrift:"title,1" frugal:"1,default,string" json:"title"`
Type PusherConfigType `thrift:"type,2" frugal:"2,default,PusherConfigType" json:"type"`
FormItems []*FormItem `thrift:"formItems,3" frugal:"3,default,list<FormItem>" json:"formItems"`
}
func NewPusherOption() *PusherOption {
return &PusherOption{}
}
func (p *PusherOption) InitDefault() {
*p = PusherOption{}
}
func (p *PusherOption) GetTitle() (v string) {
return p.Title
}
func (p *PusherOption) GetType() (v PusherConfigType) {
return p.Type
}
func (p *PusherOption) GetFormItems() (v []*FormItem) {
return p.FormItems
}
func (p *PusherOption) SetTitle(val string) {
p.Title = val
}
func (p *PusherOption) SetType(val PusherConfigType) {
p.Type = val
}
func (p *PusherOption) SetFormItems(val []*FormItem) {
p.FormItems = val
}
var fieldIDToName_PusherOption = map[int16]string{
1: "title",
2: "type",
3: "formItems",
}
func (p *PusherOption) Read(iprot thrift.TProtocol) (err error) {
var fieldTypeId thrift.TType
var fieldId int16
if _, err = iprot.ReadStructBegin(); err != nil {
goto ReadStructBeginError
}
for {
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
if err != nil {
goto ReadFieldBeginError
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err = p.ReadField1(iprot); err != nil {
goto ReadFieldError
}
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 2:
if fieldTypeId == thrift.I32 {
if err = p.ReadField2(iprot); err != nil {
goto ReadFieldError
}
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 3:
if fieldTypeId == thrift.LIST {
if err = p.ReadField3(iprot); err != nil {
goto ReadFieldError
}
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
default:
if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
}
if err = iprot.ReadFieldEnd(); err != nil {
goto ReadFieldEndError
}
}
if err = iprot.ReadStructEnd(); err != nil {
goto ReadStructEndError
}
return nil
ReadStructBeginError:
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
ReadFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
ReadFieldError:
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PusherOption[fieldId]), err)
SkipFieldError:
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
ReadFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
ReadStructEndError:
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
func (p *PusherOption) ReadField1(iprot thrift.TProtocol) error {
var _field string
if v, err := iprot.ReadString(); err != nil {
return err
} else {
_field = v
}
p.Title = _field
return nil
}
func (p *PusherOption) ReadField2(iprot thrift.TProtocol) error {
var _field PusherConfigType
if v, err := iprot.ReadI32(); err != nil {
return err
} else {
_field = PusherConfigType(v)
}
p.Type = _field
return nil
}
func (p *PusherOption) ReadField3(iprot thrift.TProtocol) error {
_, size, err := iprot.ReadListBegin()
if err != nil {
return err
}
_field := make([]*FormItem, 0, size)
values := make([]FormItem, size)
for i := 0; i < size; i++ {
_elem := &values[i]
if err := _elem.Read(iprot); err != nil {
return err
}
_field = append(_field, _elem)
}
if err := iprot.ReadListEnd(); err != nil {
return err
}
p.FormItems = _field
return nil
}
func (p *PusherOption) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("PusherOption"); err != nil {
goto WriteStructBeginError
}
if p != nil {
if err = p.writeField1(oprot); err != nil {
fieldId = 1
goto WriteFieldError
}
if err = p.writeField2(oprot); err != nil {
fieldId = 2
goto WriteFieldError
}
if err = p.writeField3(oprot); err != nil {
fieldId = 3
goto WriteFieldError
}
}
if err = oprot.WriteFieldStop(); err != nil {
goto WriteFieldStopError
}
if err = oprot.WriteStructEnd(); err != nil {
goto WriteStructEndError
}
return nil
WriteStructBeginError:
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
WriteFieldError:
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
WriteFieldStopError:
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
WriteStructEndError:
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
}
func (p *PusherOption) writeField1(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("title", thrift.STRING, 1); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteString(p.Title); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
}
func (p *PusherOption) writeField2(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("type", thrift.I32, 2); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteI32(int32(p.Type)); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
}
func (p *PusherOption) writeField3(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("formItems", thrift.LIST, 3); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteListBegin(thrift.STRUCT, len(p.FormItems)); err != nil {
return err
}
for _, v := range p.FormItems {
if err := v.Write(oprot); err != nil {
return err
}
}
if err := oprot.WriteListEnd(); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
}
func (p *PusherOption) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("PusherOption(%+v)", *p)
}
func (p *PusherOption) DeepEqual(ano *PusherOption) bool {
if p == ano {
return true
} else if p == nil || ano == nil {
return false
}
if !p.Field1DeepEqual(ano.Title) {
return false
}
if !p.Field2DeepEqual(ano.Type) {
return false
}
if !p.Field3DeepEqual(ano.FormItems) {
return false
}
return true
}
func (p *PusherOption) Field1DeepEqual(src string) bool {
if strings.Compare(p.Title, src) != 0 {
return false
}
return true
}
func (p *PusherOption) Field2DeepEqual(src PusherConfigType) bool {
if p.Type != src {
return false
}
return true
}
func (p *PusherOption) Field3DeepEqual(src []*FormItem) bool {
if len(p.FormItems) != len(src) {
return false
}
for i, v := range p.FormItems {
_src := src[i]
if !v.DeepEqual(_src) {
return false
}
}
return true
}
type FormItem struct { type FormItem struct {
Param string `thrift:"param,1" frugal:"1,default,string" json:"param"` Param string `thrift:"param,1" frugal:"1,default,string" json:"param"`
Type string `thrift:"type,2" frugal:"2,default,string" json:"type"` Type string `thrift:"type,2" frugal:"2,default,string" json:"type"`

View File

@ -408,6 +408,255 @@ func (p *PusherConfig) field6Length() int {
return l return l
} }
func (p *PusherOption) FastRead(buf []byte) (int, error) {
var err error
var offset int
var l int
var fieldTypeId thrift.TType
var fieldId int16
_, l, err = bthrift.Binary.ReadStructBegin(buf)
offset += l
if err != nil {
goto ReadStructBeginError
}
for {
_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
offset += l
if err != nil {
goto ReadFieldBeginError
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
l, err = p.FastReadField1(buf[offset:])
offset += l
if err != nil {
goto ReadFieldError
}
} else {
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
offset += l
if err != nil {
goto SkipFieldError
}
}
case 2:
if fieldTypeId == thrift.I32 {
l, err = p.FastReadField2(buf[offset:])
offset += l
if err != nil {
goto ReadFieldError
}
} else {
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
offset += l
if err != nil {
goto SkipFieldError
}
}
case 3:
if fieldTypeId == thrift.LIST {
l, err = p.FastReadField3(buf[offset:])
offset += l
if err != nil {
goto ReadFieldError
}
} else {
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
offset += l
if err != nil {
goto SkipFieldError
}
}
default:
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
offset += l
if err != nil {
goto SkipFieldError
}
}
l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
offset += l
if err != nil {
goto ReadFieldEndError
}
}
l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
offset += l
if err != nil {
goto ReadStructEndError
}
return offset, nil
ReadStructBeginError:
return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
ReadFieldBeginError:
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
ReadFieldError:
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PusherOption[fieldId]), err)
SkipFieldError:
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
ReadFieldEndError:
return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
ReadStructEndError:
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
func (p *PusherOption) FastReadField1(buf []byte) (int, error) {
offset := 0
if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
return offset, err
} else {
offset += l
p.Title = v
}
return offset, nil
}
func (p *PusherOption) FastReadField2(buf []byte) (int, error) {
offset := 0
if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil {
return offset, err
} else {
offset += l
p.Type = PusherConfigType(v)
}
return offset, nil
}
func (p *PusherOption) FastReadField3(buf []byte) (int, error) {
offset := 0
_, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:])
offset += l
if err != nil {
return offset, err
}
p.FormItems = make([]*FormItem, 0, size)
for i := 0; i < size; i++ {
_elem := NewFormItem()
if l, err := _elem.FastRead(buf[offset:]); err != nil {
return offset, err
} else {
offset += l
}
p.FormItems = append(p.FormItems, _elem)
}
if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil {
return offset, err
} else {
offset += l
}
return offset, nil
}
// for compatibility
func (p *PusherOption) FastWrite(buf []byte) int {
return 0
}
func (p *PusherOption) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
offset := 0
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PusherOption")
if p != nil {
offset += p.fastWriteField1(buf[offset:], binaryWriter)
offset += p.fastWriteField2(buf[offset:], binaryWriter)
offset += p.fastWriteField3(buf[offset:], binaryWriter)
}
offset += bthrift.Binary.WriteFieldStop(buf[offset:])
offset += bthrift.Binary.WriteStructEnd(buf[offset:])
return offset
}
func (p *PusherOption) BLength() int {
l := 0
l += bthrift.Binary.StructBeginLength("PusherOption")
if p != nil {
l += p.field1Length()
l += p.field2Length()
l += p.field3Length()
}
l += bthrift.Binary.FieldStopLength()
l += bthrift.Binary.StructEndLength()
return l
}
func (p *PusherOption) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
offset := 0
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "title", thrift.STRING, 1)
offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Title)
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
return offset
}
func (p *PusherOption) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int {
offset := 0
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "type", thrift.I32, 2)
offset += bthrift.Binary.WriteI32(buf[offset:], int32(p.Type))
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
return offset
}
func (p *PusherOption) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int {
offset := 0
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "formItems", thrift.LIST, 3)
listBeginOffset := offset
offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0)
var length int
for _, v := range p.FormItems {
length++
offset += v.FastWriteNocopy(buf[offset:], binaryWriter)
}
bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length)
offset += bthrift.Binary.WriteListEnd(buf[offset:])
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
return offset
}
func (p *PusherOption) field1Length() int {
l := 0
l += bthrift.Binary.FieldBeginLength("title", thrift.STRING, 1)
l += bthrift.Binary.StringLengthNocopy(p.Title)
l += bthrift.Binary.FieldEndLength()
return l
}
func (p *PusherOption) field2Length() int {
l := 0
l += bthrift.Binary.FieldBeginLength("type", thrift.I32, 2)
l += bthrift.Binary.I32Length(int32(p.Type))
l += bthrift.Binary.FieldEndLength()
return l
}
func (p *PusherOption) field3Length() int {
l := 0
l += bthrift.Binary.FieldBeginLength("formItems", thrift.LIST, 3)
l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.FormItems))
for _, v := range p.FormItems {
l += v.BLength()
}
l += bthrift.Binary.ListEndLength()
l += bthrift.Binary.FieldEndLength()
return l
}
func (p *FormItem) FastRead(buf []byte) (int, error) { func (p *FormItem) FastRead(buf []byte) (int, error) {
var err error var err error
var offset int var offset int

View File

@ -1040,7 +1040,7 @@ func (p *GetPusherOptionsResponse) FastRead(buf []byte) (int, error) {
} }
switch fieldId { switch fieldId {
case 1: case 1:
if fieldTypeId == thrift.MAP { if fieldTypeId == thrift.LIST {
l, err = p.FastReadField1(buf[offset:]) l, err = p.FastReadField1(buf[offset:])
offset += l offset += l
if err != nil { if err != nil {
@ -1091,52 +1091,27 @@ ReadStructEndError:
func (p *GetPusherOptionsResponse) FastReadField1(buf []byte) (int, error) { func (p *GetPusherOptionsResponse) FastReadField1(buf []byte) (int, error) {
offset := 0 offset := 0
_, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:])
offset += l
if err != nil {
return offset, err
}
p.Options = make(map[config.PusherConfigType][]*config.FormItem, size)
for i := 0; i < size; i++ {
var _key config.PusherConfigType
if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil {
return offset, err
} else {
offset += l
_key = config.PusherConfigType(v)
}
_, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:])
offset += l offset += l
if err != nil { if err != nil {
return offset, err return offset, err
} }
_val := make([]*config.FormItem, 0, size) p.Options = make([]*config.PusherOption, 0, size)
for i := 0; i < size; i++ { for i := 0; i < size; i++ {
_elem := config.NewFormItem() _elem := config.NewPusherOption()
if l, err := _elem.FastRead(buf[offset:]); err != nil { if l, err := _elem.FastRead(buf[offset:]); err != nil {
return offset, err return offset, err
} else { } else {
offset += l offset += l
} }
_val = append(_val, _elem) p.Options = append(p.Options, _elem)
} }
if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil {
return offset, err return offset, err
} else { } else {
offset += l offset += l
} }
p.Options[_key] = _val
}
if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil {
return offset, err
} else {
offset += l
}
return offset, nil return offset, nil
} }
@ -1169,46 +1144,28 @@ func (p *GetPusherOptionsResponse) BLength() int {
func (p *GetPusherOptionsResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { func (p *GetPusherOptionsResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
offset := 0 offset := 0
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "options", thrift.MAP, 1) offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "options", thrift.LIST, 1)
mapBeginOffset := offset
offset += bthrift.Binary.MapBeginLength(thrift.I32, thrift.LIST, 0)
var length int
for k, v := range p.Options {
length++
offset += bthrift.Binary.WriteI32(buf[offset:], int32(k))
listBeginOffset := offset listBeginOffset := offset
offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0)
var length int var length int
for _, v := range v { for _, v := range p.Options {
length++ length++
offset += v.FastWriteNocopy(buf[offset:], binaryWriter) offset += v.FastWriteNocopy(buf[offset:], binaryWriter)
} }
bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length)
offset += bthrift.Binary.WriteListEnd(buf[offset:]) offset += bthrift.Binary.WriteListEnd(buf[offset:])
}
bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I32, thrift.LIST, length)
offset += bthrift.Binary.WriteMapEnd(buf[offset:])
offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
return offset return offset
} }
func (p *GetPusherOptionsResponse) field1Length() int { func (p *GetPusherOptionsResponse) field1Length() int {
l := 0 l := 0
l += bthrift.Binary.FieldBeginLength("options", thrift.MAP, 1) l += bthrift.Binary.FieldBeginLength("options", thrift.LIST, 1)
l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.LIST, len(p.Options)) l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Options))
for k, v := range p.Options { for _, v := range p.Options {
l += bthrift.Binary.I32Length(int32(k))
l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(v))
for _, v := range v {
l += v.BLength() l += v.BLength()
} }
l += bthrift.Binary.ListEndLength() l += bthrift.Binary.ListEndLength()
}
l += bthrift.Binary.MapEndLength()
l += bthrift.Binary.FieldEndLength() l += bthrift.Binary.FieldEndLength()
return l return l
} }

View File

@ -1250,7 +1250,7 @@ func (p *ListPusherResponse) Field2DeepEqual(src []*config.PusherConfig) bool {
} }
type GetPusherOptionsResponse struct { type GetPusherOptionsResponse struct {
Options map[config.PusherConfigType][]*config.FormItem `thrift:"options,1" frugal:"1,default,map<PusherConfigType:list<config.FormItem>>" json:"options"` Options []*config.PusherOption `thrift:"options,1" frugal:"1,default,list<config.PusherOption>" json:"options"`
} }
func NewGetPusherOptionsResponse() *GetPusherOptionsResponse { func NewGetPusherOptionsResponse() *GetPusherOptionsResponse {
@ -1261,10 +1261,10 @@ func (p *GetPusherOptionsResponse) InitDefault() {
*p = GetPusherOptionsResponse{} *p = GetPusherOptionsResponse{}
} }
func (p *GetPusherOptionsResponse) GetOptions() (v map[config.PusherConfigType][]*config.FormItem) { func (p *GetPusherOptionsResponse) GetOptions() (v []*config.PusherOption) {
return p.Options return p.Options
} }
func (p *GetPusherOptionsResponse) SetOptions(val map[config.PusherConfigType][]*config.FormItem) { func (p *GetPusherOptionsResponse) SetOptions(val []*config.PusherOption) {
p.Options = val p.Options = val
} }
@ -1292,7 +1292,7 @@ func (p *GetPusherOptionsResponse) Read(iprot thrift.TProtocol) (err error) {
switch fieldId { switch fieldId {
case 1: case 1:
if fieldTypeId == thrift.MAP { if fieldTypeId == thrift.LIST {
if err = p.ReadField1(iprot); err != nil { if err = p.ReadField1(iprot); err != nil {
goto ReadFieldError goto ReadFieldError
} }
@ -1329,24 +1329,12 @@ ReadStructEndError:
} }
func (p *GetPusherOptionsResponse) ReadField1(iprot thrift.TProtocol) error { func (p *GetPusherOptionsResponse) ReadField1(iprot thrift.TProtocol) error {
_, _, size, err := iprot.ReadMapBegin()
if err != nil {
return err
}
_field := make(map[config.PusherConfigType][]*config.FormItem, size)
for i := 0; i < size; i++ {
var _key config.PusherConfigType
if v, err := iprot.ReadI32(); err != nil {
return err
} else {
_key = config.PusherConfigType(v)
}
_, size, err := iprot.ReadListBegin() _, size, err := iprot.ReadListBegin()
if err != nil { if err != nil {
return err return err
} }
_val := make([]*config.FormItem, 0, size) _field := make([]*config.PusherOption, 0, size)
values := make([]config.FormItem, size) values := make([]config.PusherOption, size)
for i := 0; i < size; i++ { for i := 0; i < size; i++ {
_elem := &values[i] _elem := &values[i]
@ -1354,17 +1342,11 @@ func (p *GetPusherOptionsResponse) ReadField1(iprot thrift.TProtocol) error {
return err return err
} }
_val = append(_val, _elem) _field = append(_field, _elem)
} }
if err := iprot.ReadListEnd(); err != nil { if err := iprot.ReadListEnd(); err != nil {
return err return err
} }
_field[_key] = _val
}
if err := iprot.ReadMapEnd(); err != nil {
return err
}
p.Options = _field p.Options = _field
return nil return nil
} }
@ -1398,20 +1380,13 @@ WriteStructEndError:
} }
func (p *GetPusherOptionsResponse) writeField1(oprot thrift.TProtocol) (err error) { func (p *GetPusherOptionsResponse) writeField1(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("options", thrift.MAP, 1); err != nil { if err = oprot.WriteFieldBegin("options", thrift.LIST, 1); err != nil {
goto WriteFieldBeginError goto WriteFieldBeginError
} }
if err := oprot.WriteMapBegin(thrift.I32, thrift.LIST, len(p.Options)); err != nil { if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Options)); err != nil {
return err return err
} }
for k, v := range p.Options { for _, v := range p.Options {
if err := oprot.WriteI32(int32(k)); err != nil {
return err
}
if err := oprot.WriteListBegin(thrift.STRUCT, len(v)); err != nil {
return err
}
for _, v := range v {
if err := v.Write(oprot); err != nil { if err := v.Write(oprot); err != nil {
return err return err
} }
@ -1419,10 +1394,6 @@ func (p *GetPusherOptionsResponse) writeField1(oprot thrift.TProtocol) (err erro
if err := oprot.WriteListEnd(); err != nil { if err := oprot.WriteListEnd(); err != nil {
return err return err
} }
}
if err := oprot.WriteMapEnd(); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil { if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError goto WriteFieldEndError
} }
@ -1453,22 +1424,16 @@ func (p *GetPusherOptionsResponse) DeepEqual(ano *GetPusherOptionsResponse) bool
return true return true
} }
func (p *GetPusherOptionsResponse) Field1DeepEqual(src map[config.PusherConfigType][]*config.FormItem) bool { func (p *GetPusherOptionsResponse) Field1DeepEqual(src []*config.PusherOption) bool {
if len(p.Options) != len(src) { if len(p.Options) != len(src) {
return false return false
} }
for k, v := range p.Options { for i, v := range p.Options {
_src := src[k] _src := src[i]
if len(v) != len(_src) { if !v.DeepEqual(_src) {
return false return false
} }
for i, v := range v {
_src1 := _src[i]
if !v.DeepEqual(_src1) {
return false
}
}
} }
return true return true
} }

View File

@ -58,6 +58,9 @@ func kitexInit() (opts []server.Option) {
opts = append(opts, server. opts = append(opts, server.
WithTransHandlerFactory(&mixTransHandlerFactory{nil})) WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
opts = append(opts, server.
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
// address // address
addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address) addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address)
if err != nil { if err != nil {