MCPcopy
hub / github.com/TarsCloud/TarsGo / GetTokensWithContext

Method GetTokensWithContext

tars/protocol/res/authf/Auth.tars.go:179–260  ·  view source on GitHub ↗

GetTokensWithContext is the proxy function for the method defined in the tars file, with the context

(tarsCtx context.Context, request *TokenRequest, opts ...map[string]string)

Source from the content-addressed store, hash-verified

177
178// GetTokensWithContext is the proxy function for the method defined in the tars file, with the context
179func (obj *Auth) GetTokensWithContext(tarsCtx context.Context, request *TokenRequest, opts ...map[string]string) (ret []TokenResponse, err error) {
180 var (
181 length int32
182 have bool
183 ty byte
184 )
185 buf := codec.NewBuffer()
186 err = request.WriteBlock(buf, 1)
187 if err != nil {
188 return ret, err
189 }
190
191 var statusMap map[string]string
192 var contextMap map[string]string
193 if len(opts) == 1 {
194 contextMap = opts[0]
195 } else if len(opts) == 2 {
196 contextMap = opts[0]
197 statusMap = opts[1]
198 }
199
200 tarsResp := new(requestf.ResponsePacket)
201 err = obj.servant.TarsInvoke(tarsCtx, 0, "getTokens", buf.ToBytes(), statusMap, contextMap, tarsResp)
202 if err != nil {
203 return ret, err
204 }
205 readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer))
206 _, ty, err = readBuf.SkipToNoCheck(0, true)
207 if err != nil {
208 return ret, err
209 }
210 if ty == codec.LIST {
211 err = readBuf.ReadInt32(&length, 0, true)
212 if err != nil {
213 return ret, err
214 }
215 ret = make([]TokenResponse, length)
216 for i0, e0 := int32(0), length; i0 < e0; i0++ {
217 err = ret[i0].ReadBlock(readBuf, 0, true)
218 if err != nil {
219 return ret, err
220 }
221 }
222 } else if ty == codec.SimpleList {
223 err = fmt.Errorf("not support SimpleList type")
224 if err != nil {
225 return ret, err
226 }
227 } else {
228 err = fmt.Errorf("require vector, but not")
229 if err != nil {
230 return ret, err
231 }
232 }
233
234 if len(opts) == 1 {
235 for k := range contextMap {
236 delete(contextMap, k)

Callers 1

GetTokensMethod · 0.95

Calls 10

ToBytesMethod · 0.95
SkipToNoCheckMethod · 0.95
ReadInt32Method · 0.95
NewBufferFunction · 0.92
NewReaderFunction · 0.92
Int8ToByteFunction · 0.92
WriteBlockMethod · 0.65
TarsInvokeMethod · 0.65
ReadBlockMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected