This commit is contained in:
parent
56f3155d99
commit
e099838d65
@ -18,9 +18,17 @@ func NewGetPusherOptionsService(ctx context.Context) *GetPusherOptionsService {
|
||||
func (s *GetPusherOptionsService) Run() (resp *push.GetPusherOptionsResponse, err error) {
|
||||
// Finish your business logic.
|
||||
resp = new(push.GetPusherOptionsResponse)
|
||||
resp.Options = map[config.PusherConfigType][]*config.FormItem{
|
||||
config.PusherConfigType_AnPush: toFormItems(config.AnPush{}),
|
||||
config.PusherConfigType_Email: toFormItems(config.EmailPush{}),
|
||||
resp.Options = []*config.PusherOption{
|
||||
{
|
||||
Title: "AnPush",
|
||||
Type: config.PusherConfigType_AnPush,
|
||||
FormItems: toFormItems(config.AnPush{}),
|
||||
},
|
||||
{
|
||||
Title: "邮箱",
|
||||
Type: config.PusherConfigType_Email,
|
||||
FormItems: toFormItems(config.EmailPush{}),
|
||||
},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -12,6 +12,12 @@ struct PusherConfig {
|
||||
6: required string option
|
||||
}
|
||||
|
||||
struct PusherOption {
|
||||
1: string title
|
||||
2: PusherConfigType type
|
||||
3: list<FormItem> formItems
|
||||
}
|
||||
|
||||
struct FormItem {
|
||||
1: string param
|
||||
2: string type
|
||||
|
@ -25,7 +25,7 @@ struct ListPusherResponse {
|
||||
}
|
||||
|
||||
struct GetPusherOptionsResponse {
|
||||
1: map<config.PusherConfigType,list<config.FormItem>> options
|
||||
1: list<config.PusherOption> options
|
||||
}
|
||||
|
||||
service PushService{
|
||||
|
@ -526,6 +526,313 @@ func (p *PusherConfig) Field6DeepEqual(src string) bool {
|
||||
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 {
|
||||
Param string `thrift:"param,1" frugal:"1,default,string" json:"param"`
|
||||
Type string `thrift:"type,2" frugal:"2,default,string" json:"type"`
|
||||
|
@ -408,6 +408,255 @@ func (p *PusherConfig) field6Length() int {
|
||||
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) {
|
||||
var err error
|
||||
var offset int
|
||||
|
@ -1040,7 +1040,7 @@ func (p *GetPusherOptionsResponse) FastRead(buf []byte) (int, error) {
|
||||
}
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.MAP {
|
||||
if fieldTypeId == thrift.LIST {
|
||||
l, err = p.FastReadField1(buf[offset:])
|
||||
offset += l
|
||||
if err != nil {
|
||||
@ -1091,48 +1091,23 @@ ReadStructEndError:
|
||||
func (p *GetPusherOptionsResponse) FastReadField1(buf []byte) (int, error) {
|
||||
offset := 0
|
||||
|
||||
_, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:])
|
||||
_, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:])
|
||||
offset += l
|
||||
if err != nil {
|
||||
return offset, err
|
||||
}
|
||||
p.Options = make(map[config.PusherConfigType][]*config.FormItem, size)
|
||||
p.Options = make([]*config.PusherOption, 0, 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:])
|
||||
offset += l
|
||||
if err != nil {
|
||||
return offset, err
|
||||
}
|
||||
_val := make([]*config.FormItem, 0, size)
|
||||
for i := 0; i < size; i++ {
|
||||
_elem := config.NewFormItem()
|
||||
if l, err := _elem.FastRead(buf[offset:]); err != nil {
|
||||
return offset, err
|
||||
} else {
|
||||
offset += l
|
||||
}
|
||||
|
||||
_val = append(_val, _elem)
|
||||
}
|
||||
if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil {
|
||||
_elem := config.NewPusherOption()
|
||||
if l, err := _elem.FastRead(buf[offset:]); err != nil {
|
||||
return offset, err
|
||||
} else {
|
||||
offset += l
|
||||
}
|
||||
|
||||
p.Options[_key] = _val
|
||||
p.Options = append(p.Options, _elem)
|
||||
}
|
||||
if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil {
|
||||
if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil {
|
||||
return offset, err
|
||||
} else {
|
||||
offset += l
|
||||
@ -1169,46 +1144,28 @@ func (p *GetPusherOptionsResponse) BLength() int {
|
||||
|
||||
func (p *GetPusherOptionsResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||
offset := 0
|
||||
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "options", thrift.MAP, 1)
|
||||
mapBeginOffset := offset
|
||||
offset += bthrift.Binary.MapBeginLength(thrift.I32, thrift.LIST, 0)
|
||||
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "options", thrift.LIST, 1)
|
||||
listBeginOffset := offset
|
||||
offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0)
|
||||
var length int
|
||||
for k, v := range p.Options {
|
||||
for _, v := range p.Options {
|
||||
length++
|
||||
|
||||
offset += bthrift.Binary.WriteI32(buf[offset:], int32(k))
|
||||
|
||||
listBeginOffset := offset
|
||||
offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0)
|
||||
var length int
|
||||
for _, v := range v {
|
||||
length++
|
||||
offset += v.FastWriteNocopy(buf[offset:], binaryWriter)
|
||||
}
|
||||
bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length)
|
||||
offset += bthrift.Binary.WriteListEnd(buf[offset:])
|
||||
offset += v.FastWriteNocopy(buf[offset:], binaryWriter)
|
||||
}
|
||||
bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I32, thrift.LIST, length)
|
||||
offset += bthrift.Binary.WriteMapEnd(buf[offset:])
|
||||
bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length)
|
||||
offset += bthrift.Binary.WriteListEnd(buf[offset:])
|
||||
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||
return offset
|
||||
}
|
||||
|
||||
func (p *GetPusherOptionsResponse) field1Length() int {
|
||||
l := 0
|
||||
l += bthrift.Binary.FieldBeginLength("options", thrift.MAP, 1)
|
||||
l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.LIST, len(p.Options))
|
||||
for k, 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 += bthrift.Binary.ListEndLength()
|
||||
l += bthrift.Binary.FieldBeginLength("options", thrift.LIST, 1)
|
||||
l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.Options))
|
||||
for _, v := range p.Options {
|
||||
l += v.BLength()
|
||||
}
|
||||
l += bthrift.Binary.MapEndLength()
|
||||
l += bthrift.Binary.ListEndLength()
|
||||
l += bthrift.Binary.FieldEndLength()
|
||||
return l
|
||||
}
|
||||
|
@ -1250,7 +1250,7 @@ func (p *ListPusherResponse) Field2DeepEqual(src []*config.PusherConfig) bool {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -1261,10 +1261,10 @@ func (p *GetPusherOptionsResponse) InitDefault() {
|
||||
*p = GetPusherOptionsResponse{}
|
||||
}
|
||||
|
||||
func (p *GetPusherOptionsResponse) GetOptions() (v map[config.PusherConfigType][]*config.FormItem) {
|
||||
func (p *GetPusherOptionsResponse) GetOptions() (v []*config.PusherOption) {
|
||||
return p.Options
|
||||
}
|
||||
func (p *GetPusherOptionsResponse) SetOptions(val map[config.PusherConfigType][]*config.FormItem) {
|
||||
func (p *GetPusherOptionsResponse) SetOptions(val []*config.PusherOption) {
|
||||
p.Options = val
|
||||
}
|
||||
|
||||
@ -1292,7 +1292,7 @@ func (p *GetPusherOptionsResponse) Read(iprot thrift.TProtocol) (err error) {
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
if fieldTypeId == thrift.MAP {
|
||||
if fieldTypeId == thrift.LIST {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
@ -1329,40 +1329,22 @@ ReadStructEndError:
|
||||
}
|
||||
|
||||
func (p *GetPusherOptionsResponse) ReadField1(iprot thrift.TProtocol) error {
|
||||
_, _, size, err := iprot.ReadMapBegin()
|
||||
_, size, err := iprot.ReadListBegin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_field := make(map[config.PusherConfigType][]*config.FormItem, size)
|
||||
_field := make([]*config.PusherOption, 0, size)
|
||||
values := make([]config.PusherOption, 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()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_val := make([]*config.FormItem, 0, size)
|
||||
values := make([]config.FormItem, size)
|
||||
for i := 0; i < size; i++ {
|
||||
_elem := &values[i]
|
||||
_elem := &values[i]
|
||||
|
||||
if err := _elem.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_val = append(_val, _elem)
|
||||
}
|
||||
if err := iprot.ReadListEnd(); err != nil {
|
||||
if err := _elem.Read(iprot); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_field[_key] = _val
|
||||
_field = append(_field, _elem)
|
||||
}
|
||||
if err := iprot.ReadMapEnd(); err != nil {
|
||||
if err := iprot.ReadListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Options = _field
|
||||
@ -1398,29 +1380,18 @@ WriteStructEndError:
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
for k, 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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := oprot.WriteListEnd(); err != nil {
|
||||
for _, v := range p.Options {
|
||||
if err := v.Write(oprot); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := oprot.WriteMapEnd(); err != nil {
|
||||
if err := oprot.WriteListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = oprot.WriteFieldEnd(); err != nil {
|
||||
@ -1453,22 +1424,16 @@ func (p *GetPusherOptionsResponse) DeepEqual(ano *GetPusherOptionsResponse) bool
|
||||
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) {
|
||||
return false
|
||||
}
|
||||
for k, v := range p.Options {
|
||||
_src := src[k]
|
||||
if len(v) != len(_src) {
|
||||
for i, v := range p.Options {
|
||||
_src := src[i]
|
||||
if !v.DeepEqual(_src) {
|
||||
return false
|
||||
}
|
||||
for i, v := range v {
|
||||
_src1 := _src[i]
|
||||
if !v.DeepEqual(_src1) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
3
main.go
3
main.go
@ -58,6 +58,9 @@ func kitexInit() (opts []server.Option) {
|
||||
opts = append(opts, server.
|
||||
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||
|
||||
opts = append(opts, server.
|
||||
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||
|
||||
// address
|
||||
addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user