/
services.go
4032 lines (3529 loc) · 108 KB
/
services.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.27.0. DO NOT EDIT.
// @generated
package services
import (
bytes "bytes"
base64 "encoding/base64"
errors "errors"
fmt "fmt"
multierr "go.uber.org/multierr"
exceptions "go.uber.org/thriftrw/gen/internal/tests/exceptions"
unions "go.uber.org/thriftrw/gen/internal/tests/unions"
thriftreflect "go.uber.org/thriftrw/thriftreflect"
wire "go.uber.org/thriftrw/wire"
zapcore "go.uber.org/zap/zapcore"
strings "strings"
)
type ConflictingNamesSetValueArgs struct {
Key string `json:"key,required"`
Value []byte `json:"value,required"`
}
// ToWire translates a ConflictingNamesSetValueArgs 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 *ConflictingNamesSetValueArgs) ToWire() (wire.Value, error) {
var (
fields [2]wire.Field
i int = 0
w wire.Value
err error
)
w, err = wire.NewValueString(v.Key), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
if v.Value == nil {
return w, errors.New("field Value of ConflictingNamesSetValueArgs is required")
}
w, err = wire.NewValueBinary(v.Value), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 2, Value: w}
i++
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a ConflictingNamesSetValueArgs 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 ConflictingNamesSetValueArgs struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v ConflictingNamesSetValueArgs
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *ConflictingNamesSetValueArgs) FromWire(w wire.Value) error {
var err error
keyIsSet := false
valueIsSet := false
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TBinary {
v.Key, err = field.Value.GetString(), error(nil)
if err != nil {
return err
}
keyIsSet = true
}
case 2:
if field.Value.Type() == wire.TBinary {
v.Value, err = field.Value.GetBinary(), error(nil)
if err != nil {
return err
}
valueIsSet = true
}
}
}
if !keyIsSet {
return errors.New("field Key of ConflictingNamesSetValueArgs is required")
}
if !valueIsSet {
return errors.New("field Value of ConflictingNamesSetValueArgs is required")
}
return nil
}
// String returns a readable string representation of a ConflictingNamesSetValueArgs
// struct.
func (v *ConflictingNamesSetValueArgs) String() string {
if v == nil {
return "<nil>"
}
var fields [2]string
i := 0
fields[i] = fmt.Sprintf("Key: %v", v.Key)
i++
fields[i] = fmt.Sprintf("Value: %v", v.Value)
i++
return fmt.Sprintf("ConflictingNamesSetValueArgs{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this ConflictingNamesSetValueArgs match the
// provided ConflictingNamesSetValueArgs.
//
// This function performs a deep comparison.
func (v *ConflictingNamesSetValueArgs) Equals(rhs *ConflictingNamesSetValueArgs) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !(v.Key == rhs.Key) {
return false
}
if !bytes.Equal(v.Value, rhs.Value) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ConflictingNamesSetValueArgs.
func (v *ConflictingNamesSetValueArgs) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
enc.AddString("key", v.Key)
enc.AddString("value", base64.StdEncoding.EncodeToString(v.Value))
return err
}
// GetKey returns the value of Key if it is set or its
// zero value if it is unset.
func (v *ConflictingNamesSetValueArgs) GetKey() (o string) {
if v != nil {
o = v.Key
}
return
}
// GetValue returns the value of Value if it is set or its
// zero value if it is unset.
func (v *ConflictingNamesSetValueArgs) GetValue() (o []byte) {
if v != nil {
o = v.Value
}
return
}
// IsSetValue returns true if Value is not nil.
func (v *ConflictingNamesSetValueArgs) IsSetValue() bool {
return v != nil && v.Value != nil
}
type InternalError struct {
Message *string `json:"message,omitempty"`
}
// ToWire translates a InternalError 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 *InternalError) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.Message != nil {
w, err = wire.NewValueString(*(v.Message)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
}
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a InternalError 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 InternalError struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v InternalError
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *InternalError) FromWire(w wire.Value) error {
var err error
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TBinary {
var x string
x, err = field.Value.GetString(), error(nil)
v.Message = &x
if err != nil {
return err
}
}
}
}
return nil
}
// String returns a readable string representation of a InternalError
// struct.
func (v *InternalError) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Message != nil {
fields[i] = fmt.Sprintf("Message: %v", *(v.Message))
i++
}
return fmt.Sprintf("InternalError{%v}", strings.Join(fields[:i], ", "))
}
// ErrorName is the name of this type as defined in the Thrift
// file.
func (*InternalError) ErrorName() string {
return "InternalError"
}
func _String_EqualsPtr(lhs, rhs *string) bool {
if lhs != nil && rhs != nil {
x := *lhs
y := *rhs
return (x == y)
}
return lhs == nil && rhs == nil
}
// Equals returns true if all the fields of this InternalError match the
// provided InternalError.
//
// This function performs a deep comparison.
func (v *InternalError) Equals(rhs *InternalError) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_String_EqualsPtr(v.Message, rhs.Message) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of InternalError.
func (v *InternalError) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Message != nil {
enc.AddString("message", *v.Message)
}
return err
}
// GetMessage returns the value of Message if it is set or its
// zero value if it is unset.
func (v *InternalError) GetMessage() (o string) {
if v != nil && v.Message != nil {
return *v.Message
}
return
}
// IsSetMessage returns true if Message is not nil.
func (v *InternalError) IsSetMessage() bool {
return v != nil && v.Message != nil
}
func (v *InternalError) Error() string {
return v.String()
}
type Key string
// KeyPtr returns a pointer to a Key
func (v Key) Ptr() *Key {
return &v
}
// ToWire translates Key into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
func (v Key) ToWire() (wire.Value, error) {
x := (string)(v)
return wire.NewValueString(x), error(nil)
}
// String returns a readable string representation of Key.
func (v Key) String() string {
x := (string)(v)
return fmt.Sprint(x)
}
// FromWire deserializes Key from its Thrift-level
// representation. The Thrift-level representation may be obtained
// from a ThriftRW protocol implementation.
func (v *Key) FromWire(w wire.Value) error {
x, err := w.GetString(), error(nil)
*v = (Key)(x)
return err
}
// Equals returns true if this Key is equal to the provided
// Key.
func (lhs Key) Equals(rhs Key) bool {
return ((string)(lhs) == (string)(rhs))
}
// ThriftModule represents the IDL file used to generate this package.
var ThriftModule = &thriftreflect.ThriftModule{
Name: "services",
Package: "go.uber.org/thriftrw/gen/internal/tests/services",
FilePath: "services.thrift",
SHA1: "22d2183c133fb327925d7288a6191b17e8f28175",
Includes: []*thriftreflect.ThriftModule{
exceptions.ThriftModule,
unions.ThriftModule,
},
Raw: rawIDL,
}
const rawIDL = "include \"./unions.thrift\"\ninclude \"./exceptions.thrift\"\n\ntypedef string Key\n\nexception InternalError {\n 1: optional string message\n}\n\nservice KeyValue {\n // void and no exceptions\n void setValue(1: Key key, 2: unions.ArbitraryValue value)\n\n void setValueV2(\n /** Key to change. */\n 1: required Key key,\n /**\n * New value for the key.\n *\n * If the key already has an existing value, it will be overwritten.\n */\n 2: required unions.ArbitraryValue value,\n )\n\n // Return with exceptions\n unions.ArbitraryValue getValue(1: Key key)\n throws (1: exceptions.DoesNotExistException doesNotExist)\n\n // void with exceptions\n void deleteValue(1: Key key)\n throws (\n /**\n * Raised if a value with the given key doesn't exist.\n */\n 1: exceptions.DoesNotExistException doesNotExist,\n 2: InternalError internalError\n )\n\n list<unions.ArbitraryValue> getManyValues(\n 1: list<Key> range // < reserved keyword as an argument\n ) throws (\n 1: exceptions.DoesNotExistException doesNotExist,\n )\n\n i64 size() // < primitve return value\n}\n\nservice Cache {\n oneway void clear()\n oneway void clearAfter(1: i64 durationMS)\n}\n\nstruct ConflictingNames_SetValue_Args {\n 1: required string key\n 2: required binary value\n}\n\nservice ConflictingNames {\n void setValue(1: ConflictingNames_SetValue_Args request)\n}\n\nservice non_standard_service_name {\n void non_standard_function_name()\n}\n"
// Cache_Clear_Args represents the arguments for the Cache.clear function.
//
// The arguments for clear are sent and received over the wire as this struct.
type Cache_Clear_Args struct {
}
// ToWire translates a Cache_Clear_Args 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 *Cache_Clear_Args) ToWire() (wire.Value, error) {
var (
fields [0]wire.Field
i int = 0
)
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a Cache_Clear_Args 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 Cache_Clear_Args struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v Cache_Clear_Args
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *Cache_Clear_Args) FromWire(w wire.Value) error {
for _, field := range w.GetStruct().Fields {
switch field.ID {
}
}
return nil
}
// String returns a readable string representation of a Cache_Clear_Args
// struct.
func (v *Cache_Clear_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [0]string
i := 0
return fmt.Sprintf("Cache_Clear_Args{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this Cache_Clear_Args match the
// provided Cache_Clear_Args.
//
// This function performs a deep comparison.
func (v *Cache_Clear_Args) Equals(rhs *Cache_Clear_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Cache_Clear_Args.
func (v *Cache_Clear_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
return err
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the arguments.
//
// This will always be "clear" for this struct.
func (v *Cache_Clear_Args) MethodName() string {
return "clear"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be OneWay for this struct.
func (v *Cache_Clear_Args) EnvelopeType() wire.EnvelopeType {
return wire.OneWay
}
// Cache_Clear_Helper provides functions that aid in handling the
// parameters and return values of the Cache.clear
// function.
var Cache_Clear_Helper = struct {
// Args accepts the parameters of clear in-order and returns
// the arguments struct for the function.
Args func() *Cache_Clear_Args
}{}
func init() {
Cache_Clear_Helper.Args = func() *Cache_Clear_Args {
return &Cache_Clear_Args{}
}
}
// Cache_ClearAfter_Args represents the arguments for the Cache.clearAfter function.
//
// The arguments for clearAfter are sent and received over the wire as this struct.
type Cache_ClearAfter_Args struct {
DurationMS *int64 `json:"durationMS,omitempty"`
}
// ToWire translates a Cache_ClearAfter_Args 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 *Cache_ClearAfter_Args) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.DurationMS != nil {
w, err = wire.NewValueI64(*(v.DurationMS)), error(nil)
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
}
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a Cache_ClearAfter_Args 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 Cache_ClearAfter_Args struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v Cache_ClearAfter_Args
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *Cache_ClearAfter_Args) FromWire(w wire.Value) error {
var err error
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TI64 {
var x int64
x, err = field.Value.GetI64(), error(nil)
v.DurationMS = &x
if err != nil {
return err
}
}
}
}
return nil
}
// String returns a readable string representation of a Cache_ClearAfter_Args
// struct.
func (v *Cache_ClearAfter_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.DurationMS != nil {
fields[i] = fmt.Sprintf("DurationMS: %v", *(v.DurationMS))
i++
}
return fmt.Sprintf("Cache_ClearAfter_Args{%v}", strings.Join(fields[:i], ", "))
}
func _I64_EqualsPtr(lhs, rhs *int64) bool {
if lhs != nil && rhs != nil {
x := *lhs
y := *rhs
return (x == y)
}
return lhs == nil && rhs == nil
}
// Equals returns true if all the fields of this Cache_ClearAfter_Args match the
// provided Cache_ClearAfter_Args.
//
// This function performs a deep comparison.
func (v *Cache_ClearAfter_Args) Equals(rhs *Cache_ClearAfter_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_I64_EqualsPtr(v.DurationMS, rhs.DurationMS) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Cache_ClearAfter_Args.
func (v *Cache_ClearAfter_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.DurationMS != nil {
enc.AddInt64("durationMS", *v.DurationMS)
}
return err
}
// GetDurationMS returns the value of DurationMS if it is set or its
// zero value if it is unset.
func (v *Cache_ClearAfter_Args) GetDurationMS() (o int64) {
if v != nil && v.DurationMS != nil {
return *v.DurationMS
}
return
}
// IsSetDurationMS returns true if DurationMS is not nil.
func (v *Cache_ClearAfter_Args) IsSetDurationMS() bool {
return v != nil && v.DurationMS != nil
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the arguments.
//
// This will always be "clearAfter" for this struct.
func (v *Cache_ClearAfter_Args) MethodName() string {
return "clearAfter"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be OneWay for this struct.
func (v *Cache_ClearAfter_Args) EnvelopeType() wire.EnvelopeType {
return wire.OneWay
}
// Cache_ClearAfter_Helper provides functions that aid in handling the
// parameters and return values of the Cache.clearAfter
// function.
var Cache_ClearAfter_Helper = struct {
// Args accepts the parameters of clearAfter in-order and returns
// the arguments struct for the function.
Args func(
durationMS *int64,
) *Cache_ClearAfter_Args
}{}
func init() {
Cache_ClearAfter_Helper.Args = func(
durationMS *int64,
) *Cache_ClearAfter_Args {
return &Cache_ClearAfter_Args{
DurationMS: durationMS,
}
}
}
// ConflictingNames_SetValue_Args represents the arguments for the ConflictingNames.setValue function.
//
// The arguments for setValue are sent and received over the wire as this struct.
type ConflictingNames_SetValue_Args struct {
Request *ConflictingNamesSetValueArgs `json:"request,omitempty"`
}
// ToWire translates a ConflictingNames_SetValue_Args 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 *ConflictingNames_SetValue_Args) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.Request != nil {
w, err = v.Request.ToWire()
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
}
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
func _ConflictingNamesSetValueArgs_Read(w wire.Value) (*ConflictingNamesSetValueArgs, error) {
var v ConflictingNamesSetValueArgs
err := v.FromWire(w)
return &v, err
}
// FromWire deserializes a ConflictingNames_SetValue_Args 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 ConflictingNames_SetValue_Args struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v ConflictingNames_SetValue_Args
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *ConflictingNames_SetValue_Args) FromWire(w wire.Value) error {
var err error
for _, field := range w.GetStruct().Fields {
switch field.ID {
case 1:
if field.Value.Type() == wire.TStruct {
v.Request, err = _ConflictingNamesSetValueArgs_Read(field.Value)
if err != nil {
return err
}
}
}
}
return nil
}
// String returns a readable string representation of a ConflictingNames_SetValue_Args
// struct.
func (v *ConflictingNames_SetValue_Args) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Request != nil {
fields[i] = fmt.Sprintf("Request: %v", v.Request)
i++
}
return fmt.Sprintf("ConflictingNames_SetValue_Args{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this ConflictingNames_SetValue_Args match the
// provided ConflictingNames_SetValue_Args.
//
// This function performs a deep comparison.
func (v *ConflictingNames_SetValue_Args) Equals(rhs *ConflictingNames_SetValue_Args) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !((v.Request == nil && rhs.Request == nil) || (v.Request != nil && rhs.Request != nil && v.Request.Equals(rhs.Request))) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ConflictingNames_SetValue_Args.
func (v *ConflictingNames_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Request != nil {
err = multierr.Append(err, enc.AddObject("request", v.Request))
}
return err
}
// GetRequest returns the value of Request if it is set or its
// zero value if it is unset.
func (v *ConflictingNames_SetValue_Args) GetRequest() (o *ConflictingNamesSetValueArgs) {
if v != nil && v.Request != nil {
return v.Request
}
return
}
// IsSetRequest returns true if Request is not nil.
func (v *ConflictingNames_SetValue_Args) IsSetRequest() bool {
return v != nil && v.Request != nil
}
// MethodName returns the name of the Thrift function as specified in
// the IDL, for which this struct represent the arguments.
//
// This will always be "setValue" for this struct.
func (v *ConflictingNames_SetValue_Args) MethodName() string {
return "setValue"
}
// EnvelopeType returns the kind of value inside this struct.
//
// This will always be Call for this struct.
func (v *ConflictingNames_SetValue_Args) EnvelopeType() wire.EnvelopeType {
return wire.Call
}
// ConflictingNames_SetValue_Helper provides functions that aid in handling the
// parameters and return values of the ConflictingNames.setValue
// function.
var ConflictingNames_SetValue_Helper = struct {
// Args accepts the parameters of setValue in-order and returns
// the arguments struct for the function.
Args func(
request *ConflictingNamesSetValueArgs,
) *ConflictingNames_SetValue_Args
// IsException returns true if the given error can be thrown
// by setValue.
//
// An error can be thrown by setValue only if the
// corresponding exception type was mentioned in the 'throws'
// section for it in the Thrift file.
IsException func(error) bool
// WrapResponse returns the result struct for setValue
// given the error returned by it. The provided error may
// be nil if setValue did not fail.
//
// This allows mapping errors returned by setValue into a
// serializable result struct. WrapResponse returns a
// non-nil error if the provided error cannot be thrown by
// setValue
//
// err := setValue(args)
// result, err := ConflictingNames_SetValue_Helper.WrapResponse(err)
// if err != nil {
// return fmt.Errorf("unexpected error from setValue: %v", err)
// }
// serialize(result)
WrapResponse func(error) (*ConflictingNames_SetValue_Result, error)
// UnwrapResponse takes the result struct for setValue
// and returns the erorr returned by it (if any).
//
// The error is non-nil only if setValue threw an
// exception.
//
// result := deserialize(bytes)
// err := ConflictingNames_SetValue_Helper.UnwrapResponse(result)
UnwrapResponse func(*ConflictingNames_SetValue_Result) error
}{}
func init() {
ConflictingNames_SetValue_Helper.Args = func(
request *ConflictingNamesSetValueArgs,
) *ConflictingNames_SetValue_Args {
return &ConflictingNames_SetValue_Args{
Request: request,
}
}
ConflictingNames_SetValue_Helper.IsException = func(err error) bool {
switch err.(type) {
default:
return false
}
}
ConflictingNames_SetValue_Helper.WrapResponse = func(err error) (*ConflictingNames_SetValue_Result, error) {
if err == nil {
return &ConflictingNames_SetValue_Result{}, nil
}
return nil, err
}
ConflictingNames_SetValue_Helper.UnwrapResponse = func(result *ConflictingNames_SetValue_Result) (err error) {
return
}
}
// ConflictingNames_SetValue_Result represents the result of a ConflictingNames.setValue function call.
//
// The result of a setValue execution is sent and received over the wire as this struct.
type ConflictingNames_SetValue_Result struct {
}
// ToWire translates a ConflictingNames_SetValue_Result 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 *ConflictingNames_SetValue_Result) ToWire() (wire.Value, error) {
var (
fields [0]wire.Field
i int = 0
)
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
// FromWire deserializes a ConflictingNames_SetValue_Result 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 ConflictingNames_SetValue_Result struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v ConflictingNames_SetValue_Result
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *ConflictingNames_SetValue_Result) FromWire(w wire.Value) error {
for _, field := range w.GetStruct().Fields {
switch field.ID {
}