Skip to content

Commit cae8396

Browse files
committed
code health: replace EncodeUint64 by EncodeUint
We use everywhere EncodeInt instead of EncodeInt64. Also we use everywhere EncodeUint64 instead of EncodeUint. It can be confusing. Although EncodeUint64 and EncodeUint have same logic in msgpack.v2, but different in msgpack.v5. It's good for migration to msgpack.v5 too. Part of #124.
1 parent 449ad07 commit cae8396

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

request.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ func (conn *Connection) Ping() (resp *Response, err error) {
2828
}
2929

3030
func (req *Future) fillSearch(enc *msgpack.Encoder, spaceNo, indexNo uint32, key interface{}) error {
31-
enc.EncodeUint64(KeySpaceNo)
32-
enc.EncodeUint64(uint64(spaceNo))
33-
enc.EncodeUint64(KeyIndexNo)
34-
enc.EncodeUint64(uint64(indexNo))
35-
enc.EncodeUint64(KeyKey)
31+
enc.EncodeUint(KeySpaceNo)
32+
enc.EncodeUint(uint(spaceNo))
33+
enc.EncodeUint(KeyIndexNo)
34+
enc.EncodeUint(uint(indexNo))
35+
enc.EncodeUint(KeyKey)
3636
return enc.Encode(key)
3737
}
3838

3939
func (req *Future) fillIterator(enc *msgpack.Encoder, offset, limit, iterator uint32) {
40-
enc.EncodeUint64(KeyIterator)
41-
enc.EncodeUint64(uint64(iterator))
42-
enc.EncodeUint64(KeyOffset)
43-
enc.EncodeUint64(uint64(offset))
44-
enc.EncodeUint64(KeyLimit)
45-
enc.EncodeUint64(uint64(limit))
40+
enc.EncodeUint(KeyIterator)
41+
enc.EncodeUint(uint(iterator))
42+
enc.EncodeUint(KeyOffset)
43+
enc.EncodeUint(uint(offset))
44+
enc.EncodeUint(KeyLimit)
45+
enc.EncodeUint(uint(limit))
4646
}
4747

4848
func (req *Future) fillInsert(enc *msgpack.Encoder, spaceNo uint32, tuple interface{}) error {
49-
enc.EncodeUint64(KeySpaceNo)
50-
enc.EncodeUint64(uint64(spaceNo))
51-
enc.EncodeUint64(KeyTuple)
49+
enc.EncodeUint(KeySpaceNo)
50+
enc.EncodeUint(uint(spaceNo))
51+
enc.EncodeUint(KeyTuple)
5252
return enc.Encode(tuple)
5353
}
5454

@@ -302,7 +302,7 @@ func (conn *Connection) UpdateAsync(space, index interface{}, key, ops interface
302302
if err := future.fillSearch(enc, spaceNo, indexNo, key); err != nil {
303303
return err
304304
}
305-
enc.EncodeUint64(KeyTuple)
305+
enc.EncodeUint(KeyTuple)
306306
return enc.Encode(ops)
307307
})
308308
}
@@ -317,13 +317,13 @@ func (conn *Connection) UpsertAsync(space interface{}, tuple interface{}, ops in
317317
}
318318
return future.send(conn, func(enc *msgpack.Encoder) error {
319319
enc.EncodeMapLen(3)
320-
enc.EncodeUint64(KeySpaceNo)
321-
enc.EncodeUint64(uint64(spaceNo))
322-
enc.EncodeUint64(KeyTuple)
320+
enc.EncodeUint(KeySpaceNo)
321+
enc.EncodeUint(uint(spaceNo))
322+
enc.EncodeUint(KeyTuple)
323323
if err := enc.Encode(tuple); err != nil {
324324
return err
325325
}
326-
enc.EncodeUint64(KeyDefTuple)
326+
enc.EncodeUint(KeyDefTuple)
327327
return enc.Encode(ops)
328328
})
329329
}
@@ -334,9 +334,9 @@ func (conn *Connection) CallAsync(functionName string, args interface{}) *Future
334334
future := conn.newFuture(CallRequest)
335335
return future.send(conn, func(enc *msgpack.Encoder) error {
336336
enc.EncodeMapLen(2)
337-
enc.EncodeUint64(KeyFunctionName)
337+
enc.EncodeUint(KeyFunctionName)
338338
enc.EncodeString(functionName)
339-
enc.EncodeUint64(KeyTuple)
339+
enc.EncodeUint(KeyTuple)
340340
return enc.Encode(args)
341341
})
342342
}
@@ -348,9 +348,9 @@ func (conn *Connection) Call17Async(functionName string, args interface{}) *Futu
348348
future := conn.newFuture(Call17Request)
349349
return future.send(conn, func(enc *msgpack.Encoder) error {
350350
enc.EncodeMapLen(2)
351-
enc.EncodeUint64(KeyFunctionName)
351+
enc.EncodeUint(KeyFunctionName)
352352
enc.EncodeString(functionName)
353-
enc.EncodeUint64(KeyTuple)
353+
enc.EncodeUint(KeyTuple)
354354
return enc.Encode(args)
355355
})
356356
}
@@ -360,9 +360,9 @@ func (conn *Connection) EvalAsync(expr string, args interface{}) *Future {
360360
future := conn.newFuture(EvalRequest)
361361
return future.send(conn, func(enc *msgpack.Encoder) error {
362362
enc.EncodeMapLen(2)
363-
enc.EncodeUint64(KeyExpression)
363+
enc.EncodeUint(KeyExpression)
364364
enc.EncodeString(expr)
365-
enc.EncodeUint64(KeyTuple)
365+
enc.EncodeUint(KeyTuple)
366366
return enc.Encode(args)
367367
})
368368
}
@@ -373,9 +373,9 @@ func (conn *Connection) ExecuteAsync(expr string, args interface{}) *Future {
373373
future := conn.newFuture(ExecuteRequest)
374374
return future.send(conn, func(enc *msgpack.Encoder) error {
375375
enc.EncodeMapLen(2)
376-
enc.EncodeUint64(KeySQLText)
376+
enc.EncodeUint(KeySQLText)
377377
enc.EncodeString(expr)
378-
enc.EncodeUint64(KeySQLBind)
378+
enc.EncodeUint(KeySQLBind)
379379
return encodeSQLBind(enc, args)
380380
})
381381
}

0 commit comments

Comments
 (0)