Skip to content

Commit 337ca73

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 0d266dd commit 337ca73

24 files changed

+1333
-1248
lines changed

CHANGELOG.md

+9
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 + ConnectionPool.Do() (#241)
31+
2332
### Removed
2433

2534
- multi subpackage (#240)

README.md

+6-7
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

+73-7
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,114 @@ import "time"
55
type Connector interface {
66
ConnectedNow() bool
77
Close() error
8-
Ping() (resp *Response, err error)
98
ConfiguredTimeout() time.Duration
9+
NewPrepared(expr string) (*Prepared, error)
10+
NewStream() (*Stream, error)
11+
NewWatcher(key string, callback WatchCallback) (Watcher, error)
12+
Do(req Request) (fut *Future)
1013

14+
// Deprecated: the method will be removed in the next major version,
15+
// use a PingRequest object + Do() instead.
16+
Ping() (resp *Response, err error)
17+
// Deprecated: the method will be removed in the next major version,
18+
// use a SelectRequest object + Do() instead.
1119
Select(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}) (resp *Response, err error)
20+
// Deprecated: the method will be removed in the next major version,
21+
// use an InsertRequest object + Do() instead.
1222
Insert(space interface{}, tuple interface{}) (resp *Response, err error)
23+
// Deprecated: the method will be removed in the next major version,
24+
// use a ReplicaRequest object + Do() instead.
1325
Replace(space interface{}, tuple interface{}) (resp *Response, err error)
26+
// Deprecated: the method will be removed in the next major version,
27+
// use a DeleteRequest object + Do() instead.
1428
Delete(space, index interface{}, key interface{}) (resp *Response, err error)
29+
// Deprecated: the method will be removed in the next major version,
30+
// use a UpdateRequest object + Do() instead.
1531
Update(space, index interface{}, key, ops interface{}) (resp *Response, err error)
32+
// Deprecated: the method will be removed in the next major version,
33+
// use a UpsertRequest object + Do() instead.
1634
Upsert(space interface{}, tuple, ops interface{}) (resp *Response, err error)
35+
// Deprecated: the method will be removed in the next major version,
36+
// use a CallRequest object + Do() instead.
1737
Call(functionName string, args interface{}) (resp *Response, err error)
38+
// Deprecated: the method will be removed in the next major version,
39+
// use a Call16Request object + Do() instead.
1840
Call16(functionName string, args interface{}) (resp *Response, err error)
41+
// Deprecated: the method will be removed in the next major version,
42+
// use a Call17Request object + Do() instead.
1943
Call17(functionName string, args interface{}) (resp *Response, err error)
44+
// Deprecated: the method will be removed in the next major version,
45+
// use an EvalRequest object + Do() instead.
2046
Eval(expr string, args interface{}) (resp *Response, err error)
47+
// Deprecated: the method will be removed in the next major version,
48+
// use an ExecuteRequest object + Do() instead.
2149
Execute(expr string, args interface{}) (resp *Response, err error)
2250

51+
// Deprecated: the method will be removed in the next major version,
52+
// use a SelectRequest object + Do() instead.
2353
GetTyped(space, index interface{}, key interface{}, result interface{}) (err error)
54+
// Deprecated: the method will be removed in the next major version,
55+
// use a SelectRequest object + Do() instead.
2456
SelectTyped(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}, result interface{}) (err error)
57+
// Deprecated: the method will be removed in the next major version,
58+
// use an InsertRequest object + Do() instead.
2559
InsertTyped(space interface{}, tuple interface{}, result interface{}) (err error)
60+
// Deprecated: the method will be removed in the next major version,
61+
// use a ReplaceRequest object + Do() instead.
2662
ReplaceTyped(space interface{}, tuple interface{}, result interface{}) (err error)
63+
// Deprecated: the method will be removed in the next major version,
64+
// use a DeleteRequest object + Do() instead.
2765
DeleteTyped(space, index interface{}, key interface{}, result interface{}) (err error)
66+
// Deprecated: the method will be removed in the next major version,
67+
// use a UpdateRequest object + Do() instead.
2868
UpdateTyped(space, index interface{}, key, ops interface{}, result interface{}) (err error)
69+
// Deprecated: the method will be removed in the next major version,
70+
// use a CallRequest object + Do() instead.
2971
CallTyped(functionName string, args interface{}, result interface{}) (err error)
72+
// Deprecated: the method will be removed in the next major version,
73+
// use a Call16Request object + Do() instead.
3074
Call16Typed(functionName string, args interface{}, result interface{}) (err error)
75+
// Deprecated: the method will be removed in the next major version,
76+
// use a Call17Request object + Do() instead.
3177
Call17Typed(functionName string, args interface{}, result interface{}) (err error)
78+
// Deprecated: the method will be removed in the next major version,
79+
// use an EvalRequest object + Do() instead.
3280
EvalTyped(expr string, args interface{}, result interface{}) (err error)
81+
// Deprecated: the method will be removed in the next major version,
82+
// use an ExecuteRequest object + Do() instead.
3383
ExecuteTyped(expr string, args interface{}, result interface{}) (SQLInfo, []ColumnMetaData, error)
3484

85+
// Deprecated: the method will be removed in the next major version,
86+
// use a SelectRequest object + Do() instead.
3587
SelectAsync(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}) *Future
88+
// Deprecated: the method will be removed in the next major version,
89+
// use an InsertRequest object + Do() instead.
3690
InsertAsync(space interface{}, tuple interface{}) *Future
91+
// Deprecated: the method will be removed in the next major version,
92+
// use a ReplaceRequest object + Do() instead.
3793
ReplaceAsync(space interface{}, tuple interface{}) *Future
94+
// Deprecated: the method will be removed in the next major version,
95+
// use a DeleteRequest object + Do() instead.
3896
DeleteAsync(space, index interface{}, key interface{}) *Future
97+
// Deprecated: the method will be removed in the next major version,
98+
// use a UpdateRequest object + Do() instead.
3999
UpdateAsync(space, index interface{}, key, ops interface{}) *Future
100+
// Deprecated: the method will be removed in the next major version,
101+
// use a UpsertRequest object + Do() instead.
40102
UpsertAsync(space interface{}, tuple interface{}, ops interface{}) *Future
103+
// Deprecated: the method will be removed in the next major version,
104+
// use a CallRequest object + Do() instead.
41105
CallAsync(functionName string, args interface{}) *Future
106+
// Deprecated: the method will be removed in the next major version,
107+
// use a Call16Request object + Do() instead.
42108
Call16Async(functionName string, args interface{}) *Future
109+
// Deprecated: the method will be removed in the next major version,
110+
// use a Call17Request object + Do() instead.
43111
Call17Async(functionName string, args interface{}) *Future
112+
// Deprecated: the method will be removed in the next major version,
113+
// use an EvalRequest object + Do() instead.
44114
EvalAsync(expr string, args interface{}) *Future
115+
// Deprecated: the method will be removed in the next major version,
116+
// use an ExecuteRequest object + Do() instead.
45117
ExecuteAsync(expr string, args interface{}) *Future
46-
47-
NewPrepared(expr string) (*Prepared, error)
48-
NewStream() (*Stream, error)
49-
NewWatcher(key string, callback WatchCallback) (Watcher, error)
50-
51-
Do(req Request) (fut *Future)
52118
}

crud/tarantool_test.go

+21-7
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)