/
api.go
5233 lines (4630 loc) · 137 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by thriftrw v1.20.2. DO NOT EDIT.
// @generated
// Copyright (c) 2019 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package api
import (
bytes "bytes"
base64 "encoding/base64"
json "encoding/json"
errors "errors"
fmt "fmt"
multierr "go.uber.org/multierr"
thriftreflect "go.uber.org/thriftrw/thriftreflect"
wire "go.uber.org/thriftrw/wire"
zapcore "go.uber.org/zap/zapcore"
math "math"
strconv "strconv"
strings "strings"
)
// API_VERSION is the version of the plugin API.
//
// This MUST be provided in the HandshakeResponse.
const APIVersion int32 = 4
// Argument is a single Argument inside a Function.
// For,
//
// void setValue(1: string key, 2: string value)
//
// You get the arguments,
//
// Argument{Name: "Key", Type: Type{SimpleType: SimpleTypeString}}
//
// Argument{Name: "Value", Type: Type{SimpleType: SimpleTypeString}}
type Argument struct {
// Name of the argument. This is also the name of the argument field
// inside the args/result struct for that function.
Name string `json:"name,required"`
// Argument type.
Type *Type `json:"type,required"`
}
// ToWire translates a Argument struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := v.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (v *Argument) ToWire() (wire.Value, error) {
var (
fields [2]wire.Field
i int = 0
w wire.Value
err error
)
w, err = wire.NewValueString(v.Name), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
if v.Type == nil {
return w, errors.New("field Type of Argument is required")
}
w, err = v.Type.ToWire()
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 2, Value: w}
i++
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
func _Type_Read(w wire.Value) (*Type, error) {
var v Type
err := v.FromWire(w)
return &v, err
}
// FromWire deserializes a Argument struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a Argument struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v Argument
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *Argument) FromWire(w wire.Value) error {
var err error
nameIsSet := false
typeIsSet := false
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TBinary {
v.Name, err = field.Value.GetString(), error(nil)
if err != nil {
return err
}
nameIsSet = true
}
case 2:
if field.Value.Type() == wire.TStruct {
v.Type, err = _Type_Read(field.Value)
if err != nil {
return err
}
typeIsSet = true
}
}
}
if !nameIsSet {
return errors.New("field Name of Argument is required")
}
if !typeIsSet {
return errors.New("field Type of Argument is required")
}
return nil
}
// String returns a readable string representation of a Argument
// struct.
func (v *Argument) String() string {
if v == nil {
return "<nil>"
}
var fields [2]string
i := 0
fields[i] = fmt.Sprintf("Name: %v", v.Name)
i++
fields[i] = fmt.Sprintf("Type: %v", v.Type)
i++
return fmt.Sprintf("Argument{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this Argument match the
// provided Argument.
//
// This function performs a deep comparison.
func (v *Argument) Equals(rhs *Argument) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Name == rhs.Name) {
return false
}
if !v.Type.Equals(rhs.Type) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Argument.
func (v *Argument) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("name", v.Name)
err = multierr.Append(err, enc.AddObject("type", v.Type))
return err
}
// GetName returns the value of Name if it is set or its
// zero value if it is unset.
func (v *Argument) GetName() (o string) {
if v != nil {
o = v.Name
}
return
}
// GetType returns the value of Type if it is set or its
// zero value if it is unset.
func (v *Argument) GetType() (o *Type) {
if v != nil {
o = v.Type
}
return
}
// IsSetType returns true if Type is not nil.
func (v *Argument) IsSetType() bool {
return v != nil && v.Type != nil
}
// Feature is a functionality offered by a ThriftRW plugin.
type Feature int32
const (
// SERVICE_GENERATOR specifies that the plugin may generate arbitrary code
// for services defined in the Thrift file.
//
// If a plugin provides this, it MUST implement the ServiceGenerator
// service.
FeatureServiceGenerator Feature = 1
)
// Feature_Values returns all recognized values of Feature.
func Feature_Values() []Feature {
return []Feature{
FeatureServiceGenerator,
}
}
// UnmarshalText tries to decode Feature from a byte slice
// containing its name.
//
// var v Feature
// err := v.UnmarshalText([]byte("SERVICE_GENERATOR"))
func (v *Feature) UnmarshalText(value []byte) error {
switch s := string(value); s {
case "SERVICE_GENERATOR":
*v = FeatureServiceGenerator
return nil
default:
val, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return fmt.Errorf("unknown enum value %q for %q: %v", s, "Feature", err)
}
*v = Feature(val)
return nil
}
}
// MarshalText encodes Feature to text.
//
// If the enum value is recognized, its name is returned. Otherwise,
// its integer value is returned.
//
// This implements the TextMarshaler interface.
func (v Feature) MarshalText() ([]byte, error) {
switch int32(v) {
case 1:
return []byte("SERVICE_GENERATOR"), nil
}
return []byte(strconv.FormatInt(int64(v), 10)), nil
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Feature.
// Enums are logged as objects, where the value is logged with key "value", and
// if this value's name is known, the name is logged with key "name".
func (v Feature) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddInt32("value", int32(v))
switch int32(v) {
case 1:
enc.AddString("name", "SERVICE_GENERATOR")
}
return nil
}
// Ptr returns a pointer to this enum value.
func (v Feature) Ptr() *Feature {
return &v
}
// ToWire translates Feature into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// Enums are represented as 32-bit integers over the wire.
func (v Feature) ToWire() (wire.Value, error) {
return wire.NewValueI32(int32(v)), nil
}
// FromWire deserializes Feature from its Thrift-level
// representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TI32)
// if err != nil {
// return Feature(0), err
// }
//
// var v Feature
// if err := v.FromWire(x); err != nil {
// return Feature(0), err
// }
// return v, nil
func (v *Feature) FromWire(w wire.Value) error {
*v = (Feature)(w.GetI32())
return nil
}
// String returns a readable string representation of Feature.
func (v Feature) String() string {
w := int32(v)
switch w {
case 1:
return "SERVICE_GENERATOR"
}
return fmt.Sprintf("Feature(%d)", w)
}
// Equals returns true if this Feature value matches the provided
// value.
func (v Feature) Equals(rhs Feature) bool {
return v == rhs
}
// MarshalJSON serializes Feature into JSON.
//
// If the enum value is recognized, its name is returned. Otherwise,
// its integer value is returned.
//
// This implements json.Marshaler.
func (v Feature) MarshalJSON() ([]byte, error) {
switch int32(v) {
case 1:
return ([]byte)("\"SERVICE_GENERATOR\""), nil
}
return ([]byte)(strconv.FormatInt(int64(v), 10)), nil
}
// UnmarshalJSON attempts to decode Feature from its JSON
// representation.
//
// This implementation supports both, numeric and string inputs. If a
// string is provided, it must be a known enum name.
//
// This implements json.Unmarshaler.
func (v *Feature) UnmarshalJSON(text []byte) error {
d := json.NewDecoder(bytes.NewReader(text))
d.UseNumber()
t, err := d.Token()
if err != nil {
return err
}
switch w := t.(type) {
case json.Number:
x, err := w.Int64()
if err != nil {
return err
}
if x > math.MaxInt32 {
return fmt.Errorf("enum overflow from JSON %q for %q", text, "Feature")
}
if x < math.MinInt32 {
return fmt.Errorf("enum underflow from JSON %q for %q", text, "Feature")
}
*v = (Feature)(x)
return nil
case string:
return v.UnmarshalText([]byte(w))
default:
return fmt.Errorf("invalid JSON value %q (%T) to unmarshal into %q", t, t, "Feature")
}
}
// Function is a single function on a Thrift service.
type Function struct {
// Name of the Go function.
Name string `json:"name,required"`
// Name of the function as defined in the Thrift file.
ThriftName string `json:"thriftName,required"`
// List of arguments accepted by the function.
//
// This list is in the order specified by the user in the Thrift file.
Arguments []*Argument `json:"arguments,required"`
// Return type of the function, if any. If this is not set, the function
// is a void function.
ReturnType *Type `json:"returnType,omitempty"`
// List of exceptions raised by the function.
//
// This list is in the order specified by the user in the Thrift file.
Exceptions []*Argument `json:"exceptions,omitempty"`
// Whether this function is oneway or not. This should be assumed to be
// false unless explicitly stated otherwise. If this is true, the
// returnType and exceptions will be null or empty.
OneWay *bool `json:"oneWay,omitempty"`
// Annotations defined on this function.
//
// Given,
//
// void setValue(1: SetValueRequest req) (cache = "false")
//
// The annotations will be,
//
// {
// "cache": "false",
// }
Annotations map[string]string `json:"annotations,omitempty"`
}
type _List_Argument_ValueList []*Argument
func (v _List_Argument_ValueList) ForEach(f func(wire.Value) error) error {
for i, x := range v {
if x == nil {
return fmt.Errorf("invalid [%v]: value is nil", i)
}
w, err := x.ToWire()
if err != nil {
return err
}
err = f(w)
if err != nil {
return err
}
}
return nil
}
func (v _List_Argument_ValueList) Size() int {
return len(v)
}
func (_List_Argument_ValueList) ValueType() wire.Type {
return wire.TStruct
}
func (_List_Argument_ValueList) Close() {}
type _Map_String_String_MapItemList map[string]string
func (m _Map_String_String_MapItemList) ForEach(f func(wire.MapItem) error) error {
for k, v := range m {
kw, err := wire.NewValueString(k), error(nil)
if err != nil {
return err
}
vw, err := wire.NewValueString(v), error(nil)
if err != nil {
return err
}
err = f(wire.MapItem{Key: kw, Value: vw})
if err != nil {
return err
}
}
return nil
}
func (m _Map_String_String_MapItemList) Size() int {
return len(m)
}
func (_Map_String_String_MapItemList) KeyType() wire.Type {
return wire.TBinary
}
func (_Map_String_String_MapItemList) ValueType() wire.Type {
return wire.TBinary
}
func (_Map_String_String_MapItemList) Close() {}
// ToWire translates a Function struct into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
//
// An error is returned if the struct or any of its fields failed to
// validate.
//
// x, err := v.ToWire()
// if err != nil {
// return err
// }
//
// if err := binaryProtocol.Encode(x, writer); err != nil {
// return err
// }
func (v *Function) ToWire() (wire.Value, error) {
var (
fields [7]wire.Field
i int = 0
w wire.Value
err error
)
w, err = wire.NewValueString(v.Name), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
w, err = wire.NewValueString(v.ThriftName), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 2, Value: w}
i++
if v.Arguments == nil {
return w, errors.New("field Arguments of Function is required")
}
w, err = wire.NewValueList(_List_Argument_ValueList(v.Arguments)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 3, Value: w}
i++
if v.ReturnType != nil {
w, err = v.ReturnType.ToWire()
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 4, Value: w}
i++
}
if v.Exceptions != nil {
w, err = wire.NewValueList(_List_Argument_ValueList(v.Exceptions)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 5, Value: w}
i++
}
if v.OneWay != nil {
w, err = wire.NewValueBool(*(v.OneWay)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 6, Value: w}
i++
}
if v.Annotations != nil {
w, err = wire.NewValueMap(_Map_String_String_MapItemList(v.Annotations)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 7, Value: w}
i++
}
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
func _Argument_Read(w wire.Value) (*Argument, error) {
var v Argument
err := v.FromWire(w)
return &v, err
}
func _List_Argument_Read(l wire.ValueList) ([]*Argument, error) {
if l.ValueType() != wire.TStruct {
return nil, nil
}
o := make([]*Argument, 0, l.Size())
err := l.ForEach(func(x wire.Value) error {
i, err := _Argument_Read(x)
if err != nil {
return err
}
o = append(o, i)
return nil
})
l.Close()
return o, err
}
func _Map_String_String_Read(m wire.MapItemList) (map[string]string, error) {
if m.KeyType() != wire.TBinary {
return nil, nil
}
if m.ValueType() != wire.TBinary {
return nil, nil
}
o := make(map[string]string, m.Size())
err := m.ForEach(func(x wire.MapItem) error {
k, err := x.Key.GetString(), error(nil)
if err != nil {
return err
}
v, err := x.Value.GetString(), error(nil)
if err != nil {
return err
}
o[k] = v
return nil
})
m.Close()
return o, err
}
// FromWire deserializes a Function struct from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
//
// An error is returned if we were unable to build a Function struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v Function
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *Function) FromWire(w wire.Value) error {
var err error
nameIsSet := false
thriftNameIsSet := false
argumentsIsSet := false
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TBinary {
v.Name, err = field.Value.GetString(), error(nil)
if err != nil {
return err
}
nameIsSet = true
}
case 2:
if field.Value.Type() == wire.TBinary {
v.ThriftName, err = field.Value.GetString(), error(nil)
if err != nil {
return err
}
thriftNameIsSet = true
}
case 3:
if field.Value.Type() == wire.TList {
v.Arguments, err = _List_Argument_Read(field.Value.GetList())
if err != nil {
return err
}
argumentsIsSet = true
}
case 4:
if field.Value.Type() == wire.TStruct {
v.ReturnType, err = _Type_Read(field.Value)
if err != nil {
return err
}
}
case 5:
if field.Value.Type() == wire.TList {
v.Exceptions, err = _List_Argument_Read(field.Value.GetList())
if err != nil {
return err
}
}
case 6:
if field.Value.Type() == wire.TBool {
var x bool
x, err = field.Value.GetBool(), error(nil)
v.OneWay = &x
if err != nil {
return err
}
}
case 7:
if field.Value.Type() == wire.TMap {
v.Annotations, err = _Map_String_String_Read(field.Value.GetMap())
if err != nil {
return err
}
}
}
}
if !nameIsSet {
return errors.New("field Name of Function is required")
}
if !thriftNameIsSet {
return errors.New("field ThriftName of Function is required")
}
if !argumentsIsSet {
return errors.New("field Arguments of Function is required")
}
return nil
}
// String returns a readable string representation of a Function
// struct.
func (v *Function) String() string {
if v == nil {
return "<nil>"
}
var fields [7]string
i := 0
fields[i] = fmt.Sprintf("Name: %v", v.Name)
i++
fields[i] = fmt.Sprintf("ThriftName: %v", v.ThriftName)
i++
fields[i] = fmt.Sprintf("Arguments: %v", v.Arguments)
i++
if v.ReturnType != nil {
fields[i] = fmt.Sprintf("ReturnType: %v", v.ReturnType)
i++
}
if v.Exceptions != nil {
fields[i] = fmt.Sprintf("Exceptions: %v", v.Exceptions)
i++
}
if v.OneWay != nil {
fields[i] = fmt.Sprintf("OneWay: %v", *(v.OneWay))
i++
}
if v.Annotations != nil {
fields[i] = fmt.Sprintf("Annotations: %v", v.Annotations)
i++
}
return fmt.Sprintf("Function{%v}", strings.Join(fields[:i], ", "))
}
func _List_Argument_Equals(lhs, rhs []*Argument) bool {
if len(lhs) != len(rhs) {
return false
}
for i, lv := range lhs {
rv := rhs[i]
if !lv.Equals(rv) {
return false
}
}
return true
}
func _Bool_EqualsPtr(lhs, rhs *bool) bool {
if lhs != nil && rhs != nil {
x := *lhs
y := *rhs
return (x == y)
}
return lhs == nil && rhs == nil
}
func _Map_String_String_Equals(lhs, rhs map[string]string) bool {
if len(lhs) != len(rhs) {
return false
}
for lk, lv := range lhs {
rv, ok := rhs[lk]
if !ok {
return false
}
if !(lv == rv) {
return false
}
}
return true
}
// Equals returns true if all the fields of this Function match the
// provided Function.
//
// This function performs a deep comparison.
func (v *Function) Equals(rhs *Function) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Name == rhs.Name) {
return false
}
if !(v.ThriftName == rhs.ThriftName) {
return false
}
if !_List_Argument_Equals(v.Arguments, rhs.Arguments) {
return false
}
if !((v.ReturnType == nil && rhs.ReturnType == nil) || (v.ReturnType != nil && rhs.ReturnType != nil && v.ReturnType.Equals(rhs.ReturnType))) {
return false
}
if !((v.Exceptions == nil && rhs.Exceptions == nil) || (v.Exceptions != nil && rhs.Exceptions != nil && _List_Argument_Equals(v.Exceptions, rhs.Exceptions))) {
return false
}
if !_Bool_EqualsPtr(v.OneWay, rhs.OneWay) {
return false
}
if !((v.Annotations == nil && rhs.Annotations == nil) || (v.Annotations != nil && rhs.Annotations != nil && _Map_String_String_Equals(v.Annotations, rhs.Annotations))) {
return false
}
return true
}
type _List_Argument_Zapper []*Argument
// MarshalLogArray implements zapcore.ArrayMarshaler, enabling
// fast logging of _List_Argument_Zapper.
func (l _List_Argument_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) {
for _, v := range l {
err = multierr.Append(err, enc.AppendObject(v))
}
return err
}
type _Map_String_String_Zapper map[string]string
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of _Map_String_String_Zapper.
func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
for k, v := range m {
enc.AddString((string)(k), v)
}
return err
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Function.
func (v *Function) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("name", v.Name)
enc.AddString("thriftName", v.ThriftName)
err = multierr.Append(err, enc.AddArray("arguments", (_List_Argument_Zapper)(v.Arguments)))
if v.ReturnType != nil {
err = multierr.Append(err, enc.AddObject("returnType", v.ReturnType))
}
if v.Exceptions != nil {
err = multierr.Append(err, enc.AddArray("exceptions", (_List_Argument_Zapper)(v.Exceptions)))
}
if v.OneWay != nil {
enc.AddBool("oneWay", *v.OneWay)
}
if v.Annotations != nil {
err = multierr.Append(err, enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations)))
}
return err
}
// GetName returns the value of Name if it is set or its
// zero value if it is unset.
func (v *Function) GetName() (o string) {
if v != nil {
o = v.Name
}
return
}
// GetThriftName returns the value of ThriftName if it is set or its
// zero value if it is unset.
func (v *Function) GetThriftName() (o string) {
if v != nil {
o = v.ThriftName
}
return
}
// GetArguments returns the value of Arguments if it is set or its
// zero value if it is unset.
func (v *Function) GetArguments() (o []*Argument) {
if v != nil {
o = v.Arguments
}
return
}
// IsSetArguments returns true if Arguments is not nil.
func (v *Function) IsSetArguments() bool {
return v != nil && v.Arguments != nil
}
// GetReturnType returns the value of ReturnType if it is set or its
// zero value if it is unset.
func (v *Function) GetReturnType() (o *Type) {
if v != nil && v.ReturnType != nil {
return v.ReturnType
}
return
}
// IsSetReturnType returns true if ReturnType is not nil.
func (v *Function) IsSetReturnType() bool {
return v != nil && v.ReturnType != nil
}
// GetExceptions returns the value of Exceptions if it is set or its
// zero value if it is unset.
func (v *Function) GetExceptions() (o []*Argument) {
if v != nil && v.Exceptions != nil {
return v.Exceptions
}
return
}
// IsSetExceptions returns true if Exceptions is not nil.
func (v *Function) IsSetExceptions() bool {
return v != nil && v.Exceptions != nil
}
// GetOneWay returns the value of OneWay if it is set or its
// zero value if it is unset.
func (v *Function) GetOneWay() (o bool) {
if v != nil && v.OneWay != nil {
return *v.OneWay
}
return
}
// IsSetOneWay returns true if OneWay is not nil.
func (v *Function) IsSetOneWay() bool {
return v != nil && v.OneWay != nil
}
// GetAnnotations returns the value of Annotations if it is set or its
// zero value if it is unset.
func (v *Function) GetAnnotations() (o map[string]string) {
if v != nil && v.Annotations != nil {
return v.Annotations
}
return
}
// IsSetAnnotations returns true if Annotations is not nil.
func (v *Function) IsSetAnnotations() bool {
return v != nil && v.Annotations != nil
}
// GenerateServiceRequest is a request to generate code for zero or more
// Thrift services.
type GenerateServiceRequest struct {
// IDs of services for which code should be generated.
//
// Note that the services map contains information about both, the
// services being generated and their transitive dependencies. Code should
// only be generated for service IDs listed here.
RootServices []ServiceID `json:"rootServices,required"`
// Map of service ID to service.
//
// Any service IDs present in this request will have a corresponding
// service definition in this map, including services for which code does
// not need to be generated.
Services map[ServiceID]*Service `json:"services,required"`