Skip to content

Commit e2c68d7

Browse files
committed
1 parent 8bc3a16 commit e2c68d7

6 files changed

+53
-37
lines changed

client_tools.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type IntKey struct {
88

99
func (k IntKey) encodeMsgpackImpl(enc *Encoder) error {
1010
enc.EncodeArrayLen(1)
11-
enc.EncodeInt(k.I)
11+
enc.encodeIntImpl(int64(k.I))
1212
return nil
1313
}
1414

@@ -20,7 +20,7 @@ type UintKey struct {
2020

2121
func (k UintKey) encodeMsgpackImpl(enc *Encoder) error {
2222
enc.EncodeArrayLen(1)
23-
enc.EncodeUint(k.I)
23+
enc.encodeUintImpl(uint64(k.I))
2424
return nil
2525
}
2626

@@ -44,8 +44,8 @@ type IntIntKey struct {
4444

4545
func (k IntIntKey) encodeMsgpackImpl(enc *Encoder) error {
4646
enc.EncodeArrayLen(2)
47-
enc.EncodeInt(k.I1)
48-
enc.EncodeInt(k.I2)
47+
enc.encodeIntImpl(int64(k.I1))
48+
enc.encodeIntImpl(int64(k.I2))
4949
return nil
5050
}
5151

@@ -59,7 +59,7 @@ type Op struct {
5959
func (o Op) encodeMsgpackImpl(enc *Encoder) error {
6060
enc.EncodeArrayLen(3)
6161
enc.EncodeString(o.Op)
62-
enc.EncodeInt(o.Field)
62+
enc.encodeIntImpl(int64(o.Field))
6363
return enc.Encode(o.Arg)
6464
}
6565

@@ -74,9 +74,9 @@ type OpSplice struct {
7474
func (o OpSplice) encodeMsgpackImpl(enc *Encoder) error {
7575
enc.EncodeArrayLen(5)
7676
enc.EncodeString(o.Op)
77-
enc.EncodeInt(o.Field)
78-
enc.EncodeInt(o.Pos)
79-
enc.EncodeInt(o.Len)
77+
enc.encodeIntImpl(int64(o.Field))
78+
enc.encodeIntImpl(int64(o.Pos))
79+
enc.encodeIntImpl(int64(o.Len))
8080
enc.EncodeString(o.Replace)
8181
return nil
8282
}

example_custom_unpacking_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (c *Tuple2) encodeMsgpackImpl(e *tarantool.Encoder) error {
2727
if err := e.EncodeArrayLen(3); err != nil {
2828
return err
2929
}
30-
if err := e.EncodeUint(c.Cid); err != nil {
30+
if err := e.EncodeUintImpl(uint64(c.Cid)); err != nil {
3131
return err
3232
}
3333
if err := e.EncodeString(c.Orig); err != nil {

export_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ func SslDialTimeout(network, address string, timeout time.Duration,
1717
func SslCreateContext(opts SslOpts) (ctx interface{}, err error) {
1818
return sslCreateContext(opts)
1919
}
20+
21+
func (e *Encoder) EncodeUintImpl(v uint64) error {
22+
return e.encodeUintImpl(v)
23+
}
24+
25+
func (e *Encoder) EncodeIntImpl(v int64) error {
26+
return e.encodeIntImpl(v)
27+
}

msgpack.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ func newDecoder(r io.Reader) *Decoder {
2525
return &Decoder{Decoder: dec}
2626
}
2727

28+
func (e *Encoder) encodeUintImpl(v uint64) error {
29+
return e.EncodeUint(uint(v))
30+
}
31+
32+
func (e *Encoder) encodeIntImpl(v int64) error {
33+
return e.EncodeInt(int(v))
34+
}
35+
2836
func msgpackIsUint(code byte) bool {
2937
return code == msgpcode.Uint8 || code == msgpcode.Uint16 ||
3038
code == msgpcode.Uint32 || code == msgpcode.Uint64 ||

request.go

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

2828
func (req *Future) fillSearch(enc *Encoder, spaceNo, indexNo uint32, key interface{}) error {
29-
enc.EncodeUint(KeySpaceNo)
30-
enc.EncodeUint(uint(spaceNo))
31-
enc.EncodeUint(KeyIndexNo)
32-
enc.EncodeUint(uint(indexNo))
33-
enc.EncodeUint(KeyKey)
29+
enc.encodeUintImpl(KeySpaceNo)
30+
enc.encodeUintImpl(uint64(spaceNo))
31+
enc.encodeUintImpl(KeyIndexNo)
32+
enc.encodeUintImpl(uint64(indexNo))
33+
enc.encodeUintImpl(KeyKey)
3434
return enc.Encode(key)
3535
}
3636

3737
func (req *Future) fillIterator(enc *Encoder, offset, limit, iterator uint32) {
38-
enc.EncodeUint(KeyIterator)
39-
enc.EncodeUint(uint(iterator))
40-
enc.EncodeUint(KeyOffset)
41-
enc.EncodeUint(uint(offset))
42-
enc.EncodeUint(KeyLimit)
43-
enc.EncodeUint(uint(limit))
38+
enc.encodeUintImpl(KeyIterator)
39+
enc.encodeUintImpl(uint64(iterator))
40+
enc.encodeUintImpl(KeyOffset)
41+
enc.encodeUintImpl(uint64(offset))
42+
enc.encodeUintImpl(KeyLimit)
43+
enc.encodeUintImpl(uint64(limit))
4444
}
4545

4646
func (req *Future) fillInsert(enc *Encoder, spaceNo uint32, tuple interface{}) error {
47-
enc.EncodeUint(KeySpaceNo)
48-
enc.EncodeUint(uint(spaceNo))
49-
enc.EncodeUint(KeyTuple)
47+
enc.encodeUintImpl(KeySpaceNo)
48+
enc.encodeUintImpl(uint64(spaceNo))
49+
enc.encodeUintImpl(KeyTuple)
5050
return enc.Encode(tuple)
5151
}
5252

@@ -300,7 +300,7 @@ func (conn *Connection) UpdateAsync(space, index interface{}, key, ops interface
300300
if err := future.fillSearch(enc, spaceNo, indexNo, key); err != nil {
301301
return err
302302
}
303-
enc.EncodeUint(KeyTuple)
303+
enc.encodeUintImpl(KeyTuple)
304304
return enc.Encode(ops)
305305
})
306306
}
@@ -315,13 +315,13 @@ func (conn *Connection) UpsertAsync(space interface{}, tuple interface{}, ops in
315315
}
316316
return future.send(conn, func(enc *Encoder) error {
317317
enc.EncodeMapLen(3)
318-
enc.EncodeUint(KeySpaceNo)
319-
enc.EncodeUint(uint(spaceNo))
320-
enc.EncodeUint(KeyTuple)
318+
enc.encodeUintImpl(KeySpaceNo)
319+
enc.encodeUintImpl(uint64(spaceNo))
320+
enc.encodeUintImpl(KeyTuple)
321321
if err := enc.Encode(tuple); err != nil {
322322
return err
323323
}
324-
enc.EncodeUint(KeyDefTuple)
324+
enc.encodeUintImpl(KeyDefTuple)
325325
return enc.Encode(ops)
326326
})
327327
}
@@ -332,9 +332,9 @@ func (conn *Connection) CallAsync(functionName string, args interface{}) *Future
332332
future := conn.newFuture(CallRequest)
333333
return future.send(conn, func(enc *Encoder) error {
334334
enc.EncodeMapLen(2)
335-
enc.EncodeUint(KeyFunctionName)
335+
enc.encodeUintImpl(KeyFunctionName)
336336
enc.EncodeString(functionName)
337-
enc.EncodeUint(KeyTuple)
337+
enc.encodeUintImpl(KeyTuple)
338338
return enc.Encode(args)
339339
})
340340
}
@@ -346,9 +346,9 @@ func (conn *Connection) Call17Async(functionName string, args interface{}) *Futu
346346
future := conn.newFuture(Call17Request)
347347
return future.send(conn, func(enc *Encoder) error {
348348
enc.EncodeMapLen(2)
349-
enc.EncodeUint(KeyFunctionName)
349+
enc.encodeUintImpl(KeyFunctionName)
350350
enc.EncodeString(functionName)
351-
enc.EncodeUint(KeyTuple)
351+
enc.encodeUintImpl(KeyTuple)
352352
return enc.Encode(args)
353353
})
354354
}
@@ -358,9 +358,9 @@ func (conn *Connection) EvalAsync(expr string, args interface{}) *Future {
358358
future := conn.newFuture(EvalRequest)
359359
return future.send(conn, func(enc *Encoder) error {
360360
enc.EncodeMapLen(2)
361-
enc.EncodeUint(KeyExpression)
361+
enc.encodeUintImpl(KeyExpression)
362362
enc.EncodeString(expr)
363-
enc.EncodeUint(KeyTuple)
363+
enc.encodeUintImpl(KeyTuple)
364364
return enc.Encode(args)
365365
})
366366
}
@@ -371,9 +371,9 @@ func (conn *Connection) ExecuteAsync(expr string, args interface{}) *Future {
371371
future := conn.newFuture(ExecuteRequest)
372372
return future.send(conn, func(enc *Encoder) error {
373373
enc.EncodeMapLen(2)
374-
enc.EncodeUint(KeySQLText)
374+
enc.encodeUintImpl(KeySQLText)
375375
enc.EncodeString(expr)
376-
enc.EncodeUint(KeySQLBind)
376+
enc.encodeUintImpl(KeySQLBind)
377377
return encodeSQLBind(enc, args)
378378
})
379379
}

tarantool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (m *Member) encodeMsgpackImpl(e *Encoder) error {
2828
if err := e.EncodeString(m.Name); err != nil {
2929
return err
3030
}
31-
if err := e.EncodeUint(m.Val); err != nil {
31+
if err := e.EncodeUintImpl(uint64(m.Val)); err != nil {
3232
return err
3333
}
3434
return nil

0 commit comments

Comments
 (0)