forked from yarpc/yarpc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store_compareandswap.go
206 lines (186 loc) · 4.88 KB
/
store_compareandswap.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
// Code generated by thriftrw v1.3.0
// @generated
package atomic
import (
"errors"
"fmt"
"go.uber.org/thriftrw/wire"
"strings"
)
type Store_CompareAndSwap_Args struct {
Request *CompareAndSwap `json:"request,omitempty"`
}
func (v *Store_CompareAndSwap_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 _CompareAndSwap_Read(w wire.Value) (*CompareAndSwap, error) {
var v CompareAndSwap
err := v.FromWire(w)
return &v, err
}
func (v *Store_CompareAndSwap_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 = _CompareAndSwap_Read(field.Value)
if err != nil {
return err
}
}
}
}
return nil
}
func (v *Store_CompareAndSwap_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("Store_CompareAndSwap_Args{%v}", strings.Join(fields[:i], ", "))
}
func (v *Store_CompareAndSwap_Args) Equals(rhs *Store_CompareAndSwap_Args) bool {
if !((v.Request == nil && rhs.Request == nil) || (v.Request != nil && rhs.Request != nil && v.Request.Equals(rhs.Request))) {
return false
}
return true
}
func (v *Store_CompareAndSwap_Args) MethodName() string {
return "compareAndSwap"
}
func (v *Store_CompareAndSwap_Args) EnvelopeType() wire.EnvelopeType {
return wire.Call
}
var Store_CompareAndSwap_Helper = struct {
Args func(request *CompareAndSwap) *Store_CompareAndSwap_Args
IsException func(error) bool
WrapResponse func(error) (*Store_CompareAndSwap_Result, error)
UnwrapResponse func(*Store_CompareAndSwap_Result) error
}{}
func init() {
Store_CompareAndSwap_Helper.Args = func(request *CompareAndSwap) *Store_CompareAndSwap_Args {
return &Store_CompareAndSwap_Args{Request: request}
}
Store_CompareAndSwap_Helper.IsException = func(err error) bool {
switch err.(type) {
case *IntegerMismatchError:
return true
default:
return false
}
}
Store_CompareAndSwap_Helper.WrapResponse = func(err error) (*Store_CompareAndSwap_Result, error) {
if err == nil {
return &Store_CompareAndSwap_Result{}, nil
}
switch e := err.(type) {
case *IntegerMismatchError:
if e == nil {
return nil, errors.New("WrapResponse received non-nil error type with nil value for Store_CompareAndSwap_Result.Mismatch")
}
return &Store_CompareAndSwap_Result{Mismatch: e}, nil
}
return nil, err
}
Store_CompareAndSwap_Helper.UnwrapResponse = func(result *Store_CompareAndSwap_Result) (err error) {
if result.Mismatch != nil {
err = result.Mismatch
return
}
return
}
}
type Store_CompareAndSwap_Result struct {
Mismatch *IntegerMismatchError `json:"mismatch,omitempty"`
}
func (v *Store_CompareAndSwap_Result) ToWire() (wire.Value, error) {
var (
fields [1]wire.Field
i int = 0
w wire.Value
err error
)
if v.Mismatch != nil {
w, err = v.Mismatch.ToWire()
if err != nil {
return w, err
}
fields[i] = wire.Field{ID: 1, Value: w}
i++
}
if i > 1 {
return wire.Value{}, fmt.Errorf("Store_CompareAndSwap_Result should have at most one field: got %v fields", i)
}
return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
}
func _IntegerMismatchError_Read(w wire.Value) (*IntegerMismatchError, error) {
var v IntegerMismatchError
err := v.FromWire(w)
return &v, err
}
func (v *Store_CompareAndSwap_Result) 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.Mismatch, err = _IntegerMismatchError_Read(field.Value)
if err != nil {
return err
}
}
}
}
count := 0
if v.Mismatch != nil {
count++
}
if count > 1 {
return fmt.Errorf("Store_CompareAndSwap_Result should have at most one field: got %v fields", count)
}
return nil
}
func (v *Store_CompareAndSwap_Result) String() string {
if v == nil {
return "<nil>"
}
var fields [1]string
i := 0
if v.Mismatch != nil {
fields[i] = fmt.Sprintf("Mismatch: %v", v.Mismatch)
i++
}
return fmt.Sprintf("Store_CompareAndSwap_Result{%v}", strings.Join(fields[:i], ", "))
}
func (v *Store_CompareAndSwap_Result) Equals(rhs *Store_CompareAndSwap_Result) bool {
if !((v.Mismatch == nil && rhs.Mismatch == nil) || (v.Mismatch != nil && rhs.Mismatch != nil && v.Mismatch.Equals(rhs.Mismatch))) {
return false
}
return true
}
func (v *Store_CompareAndSwap_Result) MethodName() string {
return "compareAndSwap"
}
func (v *Store_CompareAndSwap_Result) EnvelopeType() wire.EnvelopeType {
return wire.Reply
}