1
1
// Package adminf comment
2
- // This file was generated by tars2go 1.1.10
2
+ // This file was generated by tars2go 1.2.1
3
3
// Generated from AdminF.tars
4
4
package adminf
5
5
@@ -14,6 +14,7 @@ import (
14
14
"github.com/TarsCloud/TarsGo/tars/protocol/res/requestf"
15
15
"github.com/TarsCloud/TarsGo/tars/protocol/tup"
16
16
"github.com/TarsCloud/TarsGo/tars/util/current"
17
+ "github.com/TarsCloud/TarsGo/tars/util/endpoint"
17
18
"github.com/TarsCloud/TarsGo/tars/util/tools"
18
19
"unsafe"
19
20
)
@@ -31,56 +32,29 @@ type AdminF struct {
31
32
servant m.Servant
32
33
}
33
34
34
- // Shutdown is the proxy function for the method defined in the tars file, with the context
35
- func (obj * AdminF ) Shutdown (opts ... map [string ]string ) (err error ) {
36
- var (
37
- length int32
38
- have bool
39
- ty byte
40
- )
41
- buf := codec .NewBuffer ()
35
+ // SetServant sets servant for the service.
36
+ func (obj * AdminF ) SetServant (servant m.Servant ) {
37
+ obj .servant = servant
38
+ }
42
39
43
- var statusMap map [string ]string
44
- var contextMap map [string ]string
45
- if len (opts ) == 1 {
46
- contextMap = opts [0 ]
47
- } else if len (opts ) == 2 {
48
- contextMap = opts [0 ]
49
- statusMap = opts [1 ]
50
- }
51
- tarsResp := new (requestf.ResponsePacket )
52
- tarsCtx := context .Background ()
40
+ // TarsSetTimeout sets the timeout for the servant which is in ms.
41
+ func (obj * AdminF ) TarsSetTimeout (timeout int ) {
42
+ obj .servant .TarsSetTimeout (timeout )
43
+ }
53
44
54
- err = obj . servant . TarsInvoke ( tarsCtx , 0 , "shutdown" , buf . ToBytes (), statusMap , contextMap , tarsResp )
55
- if err != nil {
56
- return err
57
- }
45
+ // TarsSetProtocol sets the protocol for the servant.
46
+ func ( obj * AdminF ) TarsSetProtocol ( p m. Protocol ) {
47
+ obj . servant . TarsSetProtocol ( p )
48
+ }
58
49
59
- if len (opts ) == 1 {
60
- for k := range contextMap {
61
- delete (contextMap , k )
62
- }
63
- for k , v := range tarsResp .Context {
64
- contextMap [k ] = v
65
- }
66
- } else if len (opts ) == 2 {
67
- for k := range contextMap {
68
- delete (contextMap , k )
69
- }
70
- for k , v := range tarsResp .Context {
71
- contextMap [k ] = v
72
- }
73
- for k := range statusMap {
74
- delete (statusMap , k )
75
- }
76
- for k , v := range tarsResp .Status {
77
- statusMap [k ] = v
78
- }
79
- }
80
- _ = length
81
- _ = have
82
- _ = ty
83
- return nil
50
+ // Endpoints returns all active endpoint.Endpoint
51
+ func (obj * AdminF ) Endpoints () []* endpoint.Endpoint {
52
+ return obj .servant .Endpoints ()
53
+ }
54
+
55
+ // Shutdown is the proxy function for the method defined in the tars file, with the context
56
+ func (obj * AdminF ) Shutdown (opts ... map [string ]string ) error {
57
+ return obj .ShutdownWithContext (context .Background (), opts ... )
84
58
}
85
59
86
60
// ShutdownWithContext is the proxy function for the method defined in the tars file, with the context
@@ -156,93 +130,15 @@ func (obj *AdminF) ShutdownOneWayWithContext(tarsCtx context.Context, opts ...ma
156
130
return err
157
131
}
158
132
159
- if len (opts ) == 1 {
160
- for k := range contextMap {
161
- delete (contextMap , k )
162
- }
163
- for k , v := range tarsResp .Context {
164
- contextMap [k ] = v
165
- }
166
- } else if len (opts ) == 2 {
167
- for k := range contextMap {
168
- delete (contextMap , k )
169
- }
170
- for k , v := range tarsResp .Context {
171
- contextMap [k ] = v
172
- }
173
- for k := range statusMap {
174
- delete (statusMap , k )
175
- }
176
- for k , v := range tarsResp .Status {
177
- statusMap [k ] = v
178
- }
179
- }
180
133
_ = length
181
134
_ = have
182
135
_ = ty
183
136
return nil
184
137
}
185
138
186
139
// Notify is the proxy function for the method defined in the tars file, with the context
187
- func (obj * AdminF ) Notify (command string , opts ... map [string ]string ) (ret string , err error ) {
188
- var (
189
- length int32
190
- have bool
191
- ty byte
192
- )
193
- buf := codec .NewBuffer ()
194
- err = buf .WriteString (command , 1 )
195
- if err != nil {
196
- return ret , err
197
- }
198
-
199
- var statusMap map [string ]string
200
- var contextMap map [string ]string
201
- if len (opts ) == 1 {
202
- contextMap = opts [0 ]
203
- } else if len (opts ) == 2 {
204
- contextMap = opts [0 ]
205
- statusMap = opts [1 ]
206
- }
207
- tarsResp := new (requestf.ResponsePacket )
208
- tarsCtx := context .Background ()
209
-
210
- err = obj .servant .TarsInvoke (tarsCtx , 0 , "notify" , buf .ToBytes (), statusMap , contextMap , tarsResp )
211
- if err != nil {
212
- return ret , err
213
- }
214
-
215
- readBuf := codec .NewReader (tools .Int8ToByte (tarsResp .SBuffer ))
216
- err = readBuf .ReadString (& ret , 0 , true )
217
- if err != nil {
218
- return ret , err
219
- }
220
-
221
- if len (opts ) == 1 {
222
- for k := range contextMap {
223
- delete (contextMap , k )
224
- }
225
- for k , v := range tarsResp .Context {
226
- contextMap [k ] = v
227
- }
228
- } else if len (opts ) == 2 {
229
- for k := range contextMap {
230
- delete (contextMap , k )
231
- }
232
- for k , v := range tarsResp .Context {
233
- contextMap [k ] = v
234
- }
235
- for k := range statusMap {
236
- delete (statusMap , k )
237
- }
238
- for k , v := range tarsResp .Status {
239
- statusMap [k ] = v
240
- }
241
- }
242
- _ = length
243
- _ = have
244
- _ = ty
245
- return ret , nil
140
+ func (obj * AdminF ) Notify (command string , opts ... map [string ]string ) (string , error ) {
141
+ return obj .NotifyWithContext (context .Background (), command , opts ... )
246
142
}
247
143
248
144
// NotifyWithContext is the proxy function for the method defined in the tars file, with the context
@@ -334,48 +230,12 @@ func (obj *AdminF) NotifyOneWayWithContext(tarsCtx context.Context, command stri
334
230
return ret , err
335
231
}
336
232
337
- if len (opts ) == 1 {
338
- for k := range contextMap {
339
- delete (contextMap , k )
340
- }
341
- for k , v := range tarsResp .Context {
342
- contextMap [k ] = v
343
- }
344
- } else if len (opts ) == 2 {
345
- for k := range contextMap {
346
- delete (contextMap , k )
347
- }
348
- for k , v := range tarsResp .Context {
349
- contextMap [k ] = v
350
- }
351
- for k := range statusMap {
352
- delete (statusMap , k )
353
- }
354
- for k , v := range tarsResp .Status {
355
- statusMap [k ] = v
356
- }
357
- }
358
233
_ = length
359
234
_ = have
360
235
_ = ty
361
236
return ret , nil
362
237
}
363
238
364
- // SetServant sets servant for the service.
365
- func (obj * AdminF ) SetServant (servant m.Servant ) {
366
- obj .servant = servant
367
- }
368
-
369
- // TarsSetTimeout sets the timeout for the servant which is in ms.
370
- func (obj * AdminF ) TarsSetTimeout (timeout int ) {
371
- obj .servant .TarsSetTimeout (timeout )
372
- }
373
-
374
- // TarsSetProtocol sets the protocol for the servant.
375
- func (obj * AdminF ) TarsSetProtocol (p m.Protocol ) {
376
- obj .servant .TarsSetProtocol (p )
377
- }
378
-
379
239
type AdminFServant interface {
380
240
Shutdown () (err error )
381
241
Notify (command string ) (ret string , err error )
0 commit comments