Skip to content

Commit 525d953

Browse files
committed
api: mark all request methods as deprecated
We mark all request methods as deprecated because the logic based on request methods is very difficult to extend. These methods will be removed in a next major version. The client code should prefer a request object + Do(). We have updated all examples for this purpose. Closes #241
1 parent 6cddcd7 commit 525d953

24 files changed

+1320
-1233
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
2020
- Use msgpack/v5 instead of msgpack.v2 (#236)
2121
- Call/NewCallRequest = Call17/NewCall17Request (#235)
2222

23+
### Deprecated
24+
25+
- All Connection.<Request>, Connection.<Request>Typed and
26+
Connection.<Request>Async methods. Instead you should use requests objects +
27+
Connection.Do() #241)
28+
- All ConnectionPool.<Request>, ConnectionPool.<Request>Typed and
29+
ConnectionPool.<Request>Async methods. Instead you should use requests
30+
objects + Connection.Do() (#241)
31+
2332
### Removed
2433

2534
- multi subpackage (#240)

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ func main() {
113113
if err != nil {
114114
fmt.Println("Connection refused:", err)
115115
}
116-
resp, err := conn.Insert(999, []interface{}{99999, "BB"})
116+
resp, err := conn.Do(tarantool.NewInsertRequest(999).
117+
Tuple([]interface{}{99999, "BB"}),
118+
).Get()
117119
if err != nil {
118120
fmt.Println("Error", err)
119121
fmt.Println("Code", resp.Code)
@@ -138,12 +140,9 @@ starting a session. There are two parameters:
138140
**Observation 4:** The `err` structure will be `nil` if there is no error,
139141
otherwise it will have a description which can be retrieved with `err.Error()`.
140142

141-
**Observation 5:** The `Insert` request, like almost all requests, is preceded by
142-
"`conn.`" which is the name of the object that was returned by `Connect()`.
143-
There are two parameters:
144-
145-
* a space number (it could just as easily have been a space name), and
146-
* a tuple.
143+
**Observation 5:** The `Insert` request, like almost all requests, is preceded
144+
by the method `Do` of object `conn` which is the object that was returned
145+
by `Connect()`.
147146

148147
### Migration to v2
149148

connector.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,106 @@ type Connector interface {
88
Ping() (resp *Response, err error)
99
ConfiguredTimeout() time.Duration
1010

11+
// Deprecated: the method will be removed in the next major version,
12+
// use a SelectRequest object + Do() instead.
1113
Select(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}) (resp *Response, err error)
14+
// Deprecated: the method will be removed in the next major version,
15+
// use an InsertRequest object + Do() instead.
1216
Insert(space interface{}, tuple interface{}) (resp *Response, err error)
17+
// Deprecated: the method will be removed in the next major version,
18+
// use a ReplicaRequest object + Do() instead.
1319
Replace(space interface{}, tuple interface{}) (resp *Response, err error)
20+
// Deprecated: the method will be removed in the next major version,
21+
// use a DeleteRequest object + Do() instead.
1422
Delete(space, index interface{}, key interface{}) (resp *Response, err error)
23+
// Deprecated: the method will be removed in the next major version,
24+
// use a UpdateRequest object + Do() instead.
1525
Update(space, index interface{}, key, ops interface{}) (resp *Response, err error)
26+
// Deprecated: the method will be removed in the next major version,
27+
// use a UpsertRequest object + Do() instead.
1628
Upsert(space interface{}, tuple, ops interface{}) (resp *Response, err error)
29+
// Deprecated: the method will be removed in the next major version,
30+
// use a CallRequest object + Do() instead.
1731
Call(functionName string, args interface{}) (resp *Response, err error)
32+
// Deprecated: the method will be removed in the next major version,
33+
// use a Call16Request object + Do() instead.
1834
Call16(functionName string, args interface{}) (resp *Response, err error)
35+
// Deprecated: the method will be removed in the next major version,
36+
// use a Call17Request object + Do() instead.
1937
Call17(functionName string, args interface{}) (resp *Response, err error)
38+
// Deprecated: the method will be removed in the next major version,
39+
// use an EvalRequest object + Do() instead.
2040
Eval(expr string, args interface{}) (resp *Response, err error)
41+
// Deprecated: the method will be removed in the next major version,
42+
// use an ExecuteRequest object + Do() instead.
2143
Execute(expr string, args interface{}) (resp *Response, err error)
2244

45+
// Deprecated: the method will be removed in the next major version,
46+
// use a SelectRequest object + Do() instead.
2347
GetTyped(space, index interface{}, key interface{}, result interface{}) (err error)
48+
// Deprecated: the method will be removed in the next major version,
49+
// use a SelectRequest object + Do() instead.
2450
SelectTyped(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}, result interface{}) (err error)
51+
// Deprecated: the method will be removed in the next major version,
52+
// use an InsertRequest object + Do() instead.
2553
InsertTyped(space interface{}, tuple interface{}, result interface{}) (err error)
54+
// Deprecated: the method will be removed in the next major version,
55+
// use a ReplaceRequest object + Do() instead.
2656
ReplaceTyped(space interface{}, tuple interface{}, result interface{}) (err error)
57+
// Deprecated: the method will be removed in the next major version,
58+
// use a DeleteRequest object + Do() instead.
2759
DeleteTyped(space, index interface{}, key interface{}, result interface{}) (err error)
60+
// Deprecated: the method will be removed in the next major version,
61+
// use a UpdateRequest object + Do() instead.
2862
UpdateTyped(space, index interface{}, key, ops interface{}, result interface{}) (err error)
63+
// Deprecated: the method will be removed in the next major version,
64+
// use a CallRequest object + Do() instead.
2965
CallTyped(functionName string, args interface{}, result interface{}) (err error)
66+
// Deprecated: the method will be removed in the next major version,
67+
// use a Call16Request object + Do() instead.
3068
Call16Typed(functionName string, args interface{}, result interface{}) (err error)
69+
// Deprecated: the method will be removed in the next major version,
70+
// use a Call17Request object + Do() instead.
3171
Call17Typed(functionName string, args interface{}, result interface{}) (err error)
72+
// Deprecated: the method will be removed in the next major version,
73+
// use an EvalRequest object + Do() instead.
3274
EvalTyped(expr string, args interface{}, result interface{}) (err error)
75+
// Deprecated: the method will be removed in the next major version,
76+
// use an ExecuteRequest object + Do() instead.
3377
ExecuteTyped(expr string, args interface{}, result interface{}) (SQLInfo, []ColumnMetaData, error)
3478

79+
// Deprecated: the method will be removed in the next major version,
80+
// use a SelectRequest object + Do() instead.
3581
SelectAsync(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}) *Future
82+
// Deprecated: the method will be removed in the next major version,
83+
// use an InsertRequest object + Do() instead.
3684
InsertAsync(space interface{}, tuple interface{}) *Future
85+
// Deprecated: the method will be removed in the next major version,
86+
// use a ReplaceRequest object + Do() instead.
3787
ReplaceAsync(space interface{}, tuple interface{}) *Future
88+
// Deprecated: the method will be removed in the next major version,
89+
// use a DeleteRequest object + Do() instead.
3890
DeleteAsync(space, index interface{}, key interface{}) *Future
91+
// Deprecated: the method will be removed in the next major version,
92+
// use a UpdateRequest object + Do() instead.
3993
UpdateAsync(space, index interface{}, key, ops interface{}) *Future
94+
// Deprecated: the method will be removed in the next major version,
95+
// use a UpsertRequest object + Do() instead.
4096
UpsertAsync(space interface{}, tuple interface{}, ops interface{}) *Future
97+
// Deprecated: the method will be removed in the next major version,
98+
// use a CallRequest object + Do() instead.
4199
CallAsync(functionName string, args interface{}) *Future
100+
// Deprecated: the method will be removed in the next major version,
101+
// use a Call16Request object + Do() instead.
42102
Call16Async(functionName string, args interface{}) *Future
103+
// Deprecated: the method will be removed in the next major version,
104+
// use a Call17Request object + Do() instead.
43105
Call17Async(functionName string, args interface{}) *Future
106+
// Deprecated: the method will be removed in the next major version,
107+
// use an EvalRequest object + Do() instead.
44108
EvalAsync(expr string, args interface{}) *Future
109+
// Deprecated: the method will be removed in the next major version,
110+
// use an ExecuteRequest object + Do() instead.
45111
ExecuteAsync(expr string, args interface{}) *Future
46112

47113
NewPrepared(expr string) (*Prepared, error)

crud/tarantool_test.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ func TestCrudGenerateData(t *testing.T) {
489489
for _, testCase := range testGenerateDataCases {
490490
t.Run(testCase.name, func(t *testing.T) {
491491
for i := 1010; i < 1020; i++ {
492-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
492+
req := tarantool.NewDeleteRequest(spaceName).
493+
Key([]interface{}{uint(i)})
494+
conn.Do(req).Get()
493495
}
494496

495497
resp, err := conn.Do(testCase.req).Get()
@@ -499,7 +501,9 @@ func TestCrudGenerateData(t *testing.T) {
499501
testSelectGeneratedData(t, conn, testCase.expectedTuplesCount)
500502

501503
for i := 1010; i < 1020; i++ {
502-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
504+
req := tarantool.NewDeleteRequest(spaceName).
505+
Key([]interface{}{uint(i)})
506+
conn.Do(req).Get()
503507
}
504508
})
505509
}
@@ -516,7 +520,9 @@ func TestCrudProcessData(t *testing.T) {
516520
testCrudRequestCheck(t, testCase.req, resp,
517521
err, testCase.expectedRespLen)
518522
for i := 1010; i < 1020; i++ {
519-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
523+
req := tarantool.NewDeleteRequest(spaceName).
524+
Key([]interface{}{uint(i)})
525+
conn.Do(req).Get()
520526
}
521527
})
522528
}
@@ -648,7 +654,9 @@ func TestBoolResult(t *testing.T) {
648654
}
649655

650656
for i := 1010; i < 1020; i++ {
651-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
657+
req := tarantool.NewDeleteRequest(spaceName).
658+
Key([]interface{}{uint(i)})
659+
conn.Do(req).Get()
652660
}
653661
}
654662

@@ -671,7 +679,9 @@ func TestNumberResult(t *testing.T) {
671679
}
672680

673681
for i := 1010; i < 1020; i++ {
674-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
682+
req := tarantool.NewDeleteRequest(spaceName).
683+
Key([]interface{}{uint(i)})
684+
conn.Do(req).Get()
675685
}
676686
}
677687

@@ -714,7 +724,9 @@ func TestBaseResult(t *testing.T) {
714724
}
715725

716726
for i := 1010; i < 1020; i++ {
717-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
727+
req := tarantool.NewDeleteRequest(spaceName).
728+
Key([]interface{}{uint(i)})
729+
conn.Do(req).Get()
718730
}
719731
}
720732

@@ -757,7 +769,9 @@ func TestManyResult(t *testing.T) {
757769
}
758770

759771
for i := 1010; i < 1020; i++ {
760-
conn.Delete(spaceName, nil, []interface{}{uint(i)})
772+
req := tarantool.NewDeleteRequest(spaceName).
773+
Key([]interface{}{uint(i)})
774+
conn.Do(req).Get()
761775
}
762776
}
763777

0 commit comments

Comments
 (0)