-
Notifications
You must be signed in to change notification settings - Fork 100
/
NOSERVICES.go
684 lines (587 loc) · 15 KB
/
NOSERVICES.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
// Code generated by thriftrw v1.29.2. DO NOT EDIT.
// @generated
package NOSERVICES
import (
fmt "fmt"
stream "go.uber.org/thriftrw/protocol/stream"
thriftreflect "go.uber.org/thriftrw/thriftreflect"
wire "go.uber.org/thriftrw/wire"
zapcore "go.uber.org/zap/zapcore"
strings "strings"
)
type ExWithAnnotation struct {
Foo *string `json:"foo,omitempty"`
}
// ToWire translates a ExWithAnnotation 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 *ExWithAnnotation) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.Foo != nil {
w, err = wire.NewValueString(*(v.Foo)), 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 ExWithAnnotation 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 ExWithAnnotation struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v ExWithAnnotation
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *ExWithAnnotation) 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.Foo = &x
if err != nil {
return err
}
}
}
}
return nil
}
// Encode serializes a ExWithAnnotation struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ExWithAnnotation struct could not be encoded.
func (v *ExWithAnnotation) Encode(sw stream.Writer) error {
if err := sw.WriteStructBegin(); err != nil {
return err
}
if v.Foo != nil {
if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
return err
}
if err := sw.WriteString(*(v.Foo)); err != nil {
return err
}
if err := sw.WriteFieldEnd(); err != nil {
return err
}
}
return sw.WriteStructEnd()
}
// Decode deserializes a ExWithAnnotation struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ExWithAnnotation struct could not be generated from the wire
// representation.
func (v *ExWithAnnotation) Decode(sr stream.Reader) error {
if err := sr.ReadStructBegin(); err != nil {
return err
}
fh, ok, err := sr.ReadFieldBegin()
if err != nil {
return err
}
for ok {
switch {
case fh.ID == 1 && fh.Type == wire.TBinary:
var x string
x, err = sr.ReadString()
v.Foo = &x
if err != nil {
return err
}
default:
if err := sr.Skip(fh.Type); err != nil {
return err
}
}
if err := sr.ReadFieldEnd(); err != nil {
return err
}
if fh, ok, err = sr.ReadFieldBegin(); err != nil {
return err
}
}
if err := sr.ReadStructEnd(); err != nil {
return err
}
return nil
}
// String returns a readable string representation of a ExWithAnnotation
// struct.
func (v *ExWithAnnotation) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Foo != nil {
fields[i] = fmt.Sprintf("Foo: %v", *(v.Foo))
i++
}
return fmt.Sprintf("ExWithAnnotation{%v}", strings.Join(fields[:i], ", "))
}
// ErrorName is the name of this type as defined in the Thrift
// file.
func (*ExWithAnnotation) ErrorName() string {
return "ExWithAnnotation"
}
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 ExWithAnnotation match the
// provided ExWithAnnotation.
//
// This function performs a deep comparison.
func (v *ExWithAnnotation) Equals(rhs *ExWithAnnotation) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_String_EqualsPtr(v.Foo, rhs.Foo) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ExWithAnnotation.
func (v *ExWithAnnotation) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Foo != nil {
enc.AddString("foo", *v.Foo)
}
return err
}
// GetFoo returns the value of Foo if it is set or its
// zero value if it is unset.
func (v *ExWithAnnotation) GetFoo() (o string) {
if v != nil && v.Foo != nil {
return *v.Foo
}
return
}
// IsSetFoo returns true if Foo is not nil.
func (v *ExWithAnnotation) IsSetFoo() bool {
return v != nil && v.Foo != nil
}
func (v *ExWithAnnotation) Error() string {
return v.String()
}
type ExWithoutAnnotation struct {
Bar *string `json:"bar,omitempty"`
}
// ToWire translates a ExWithoutAnnotation 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 *ExWithoutAnnotation) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.Bar != nil {
w, err = wire.NewValueString(*(v.Bar)), 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 ExWithoutAnnotation 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 ExWithoutAnnotation struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v ExWithoutAnnotation
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *ExWithoutAnnotation) 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.Bar = &x
if err != nil {
return err
}
}
}
}
return nil
}
// Encode serializes a ExWithoutAnnotation struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a ExWithoutAnnotation struct could not be encoded.
func (v *ExWithoutAnnotation) Encode(sw stream.Writer) error {
if err := sw.WriteStructBegin(); err != nil {
return err
}
if v.Bar != nil {
if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
return err
}
if err := sw.WriteString(*(v.Bar)); err != nil {
return err
}
if err := sw.WriteFieldEnd(); err != nil {
return err
}
}
return sw.WriteStructEnd()
}
// Decode deserializes a ExWithoutAnnotation struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a ExWithoutAnnotation struct could not be generated from the wire
// representation.
func (v *ExWithoutAnnotation) Decode(sr stream.Reader) error {
if err := sr.ReadStructBegin(); err != nil {
return err
}
fh, ok, err := sr.ReadFieldBegin()
if err != nil {
return err
}
for ok {
switch {
case fh.ID == 1 && fh.Type == wire.TBinary:
var x string
x, err = sr.ReadString()
v.Bar = &x
if err != nil {
return err
}
default:
if err := sr.Skip(fh.Type); err != nil {
return err
}
}
if err := sr.ReadFieldEnd(); err != nil {
return err
}
if fh, ok, err = sr.ReadFieldBegin(); err != nil {
return err
}
}
if err := sr.ReadStructEnd(); err != nil {
return err
}
return nil
}
// String returns a readable string representation of a ExWithoutAnnotation
// struct.
func (v *ExWithoutAnnotation) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Bar != nil {
fields[i] = fmt.Sprintf("Bar: %v", *(v.Bar))
i++
}
return fmt.Sprintf("ExWithoutAnnotation{%v}", strings.Join(fields[:i], ", "))
}
// ErrorName is the name of this type as defined in the Thrift
// file.
func (*ExWithoutAnnotation) ErrorName() string {
return "ExWithoutAnnotation"
}
// Equals returns true if all the fields of this ExWithoutAnnotation match the
// provided ExWithoutAnnotation.
//
// This function performs a deep comparison.
func (v *ExWithoutAnnotation) Equals(rhs *ExWithoutAnnotation) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_String_EqualsPtr(v.Bar, rhs.Bar) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of ExWithoutAnnotation.
func (v *ExWithoutAnnotation) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Bar != nil {
enc.AddString("bar", *v.Bar)
}
return err
}
// GetBar returns the value of Bar if it is set or its
// zero value if it is unset.
func (v *ExWithoutAnnotation) GetBar() (o string) {
if v != nil && v.Bar != nil {
return *v.Bar
}
return
}
// IsSetBar returns true if Bar is not nil.
func (v *ExWithoutAnnotation) IsSetBar() bool {
return v != nil && v.Bar != nil
}
func (v *ExWithoutAnnotation) Error() string {
return v.String()
}
type Struct struct {
Baz *string `json:"baz,omitempty"`
}
// ToWire translates a Struct 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 *Struct) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.Baz != nil {
w, err = wire.NewValueString(*(v.Baz)), 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 Struct 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 Struct struct
// from the provided intermediate representation.
//
// x, err := binaryProtocol.Decode(reader, wire.TStruct)
// if err != nil {
// return nil, err
// }
//
// var v Struct
// if err := v.FromWire(x); err != nil {
// return nil, err
// }
// return &v, nil
func (v *Struct) 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.Baz = &x
if err != nil {
return err
}
}
}
}
return nil
}
// Encode serializes a Struct struct directly into bytes, without going
// through an intermediary type.
//
// An error is returned if a Struct struct could not be encoded.
func (v *Struct) Encode(sw stream.Writer) error {
if err := sw.WriteStructBegin(); err != nil {
return err
}
if v.Baz != nil {
if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
return err
}
if err := sw.WriteString(*(v.Baz)); err != nil {
return err
}
if err := sw.WriteFieldEnd(); err != nil {
return err
}
}
return sw.WriteStructEnd()
}
// Decode deserializes a Struct struct directly from its Thrift-level
// representation, without going through an intemediary type.
//
// An error is returned if a Struct struct could not be generated from the wire
// representation.
func (v *Struct) Decode(sr stream.Reader) error {
if err := sr.ReadStructBegin(); err != nil {
return err
}
fh, ok, err := sr.ReadFieldBegin()
if err != nil {
return err
}
for ok {
switch {
case fh.ID == 1 && fh.Type == wire.TBinary:
var x string
x, err = sr.ReadString()
v.Baz = &x
if err != nil {
return err
}
default:
if err := sr.Skip(fh.Type); err != nil {
return err
}
}
if err := sr.ReadFieldEnd(); err != nil {
return err
}
if fh, ok, err = sr.ReadFieldBegin(); err != nil {
return err
}
}
if err := sr.ReadStructEnd(); err != nil {
return err
}
return nil
}
// String returns a readable string representation of a Struct
// struct.
func (v *Struct) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Baz != nil {
fields[i] = fmt.Sprintf("Baz: %v", *(v.Baz))
i++
}
return fmt.Sprintf("Struct{%v}", strings.Join(fields[:i], ", "))
}
// Equals returns true if all the fields of this Struct match the
// provided Struct.
//
// This function performs a deep comparison.
func (v *Struct) Equals(rhs *Struct) bool {
if v == nil {
return rhs == nil
} else if rhs == nil {
return false
}
if !_String_EqualsPtr(v.Baz, rhs.Baz) {
return false
}
return true
}
// MarshalLogObject implements zapcore.ObjectMarshaler, enabling
// fast logging of Struct.
func (v *Struct) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
if v == nil {
return nil
}
if v.Baz != nil {
enc.AddString("baz", *v.Baz)
}
return err
}
// GetBaz returns the value of Baz if it is set or its
// zero value if it is unset.
func (v *Struct) GetBaz() (o string) {
if v != nil && v.Baz != nil {
return *v.Baz
}
return
}
// IsSetBaz returns true if Baz is not nil.
func (v *Struct) IsSetBaz() bool {
return v != nil && v.Baz != nil
}
// ThriftModule represents the IDL file used to generate this package.
var ThriftModule = &thriftreflect.ThriftModule{
Name: "NOSERVICES",
Package: "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/internal/tests/NOSERVICES",
FilePath: "NOSERVICES.thrift",
SHA1: "bc28a223c8e87e320722bf77136e0eec1f1d18d6",
Raw: rawIDL,
}
const rawIDL = "// Thrift file with no service to ensure that types_yarpc.go is always\n// generated.\n\nexception ExWithAnnotation {\n 1: optional string foo\n} (\n rpc.code = \"OUT_OF_RANGE\"\n)\n\nexception ExWithoutAnnotation {\n 1: optional string bar\n}\n\nstruct Struct {\n 1: optional string baz\n}\n"