Skip to content

Commit

Permalink
api: mark all request methods as deprecated
Browse files Browse the repository at this point in the history
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
  • Loading branch information
oleg-jukovec committed Jun 19, 2023
1 parent 0d266dd commit 337ca73
Show file tree
Hide file tree
Showing 24 changed files with 1,333 additions and 1,248 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- Use msgpack/v5 instead of msgpack.v2 (#236)
- Call/NewCallRequest = Call17/NewCall17Request (#235)

### Deprecated

- All Connection.<Request>, Connection.<Request>Typed and
Connection.<Request>Async methods. Instead you should use requests objects +
Connection.Do() (#241)
- All ConnectionPool.<Request>, ConnectionPool.<Request>Typed and
ConnectionPool.<Request>Async methods. Instead you should use requests
objects + ConnectionPool.Do() (#241)

### Removed

- multi subpackage (#240)
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ func main() {
if err != nil {
fmt.Println("Connection refused:", err)
}
resp, err := conn.Insert(999, []interface{}{99999, "BB"})
resp, err := conn.Do(tarantool.NewInsertRequest(999).
Tuple([]interface{}{99999, "BB"}),
).Get()
if err != nil {
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
Expand All @@ -138,12 +140,9 @@ starting a session. There are two parameters:
**Observation 4:** The `err` structure will be `nil` if there is no error,
otherwise it will have a description which can be retrieved with `err.Error()`.

**Observation 5:** The `Insert` request, like almost all requests, is preceded by
"`conn.`" which is the name of the object that was returned by `Connect()`.
There are two parameters:

* a space number (it could just as easily have been a space name), and
* a tuple.
**Observation 5:** The `Insert` request, like almost all requests, is preceded
by the method `Do` of object `conn` which is the object that was returned
by `Connect()`.

### Migration to v2

Expand Down
80 changes: 73 additions & 7 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,114 @@ import "time"
type Connector interface {
ConnectedNow() bool
Close() error
Ping() (resp *Response, err error)
ConfiguredTimeout() time.Duration
NewPrepared(expr string) (*Prepared, error)
NewStream() (*Stream, error)
NewWatcher(key string, callback WatchCallback) (Watcher, error)
Do(req Request) (fut *Future)

// Deprecated: the method will be removed in the next major version,
// use a PingRequest object + Do() instead.
Ping() (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a SelectRequest object + Do() instead.
Select(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use an InsertRequest object + Do() instead.
Insert(space interface{}, tuple interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a ReplicaRequest object + Do() instead.
Replace(space interface{}, tuple interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a DeleteRequest object + Do() instead.
Delete(space, index interface{}, key interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a UpdateRequest object + Do() instead.
Update(space, index interface{}, key, ops interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a UpsertRequest object + Do() instead.
Upsert(space interface{}, tuple, ops interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a CallRequest object + Do() instead.
Call(functionName string, args interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a Call16Request object + Do() instead.
Call16(functionName string, args interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use a Call17Request object + Do() instead.
Call17(functionName string, args interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use an EvalRequest object + Do() instead.
Eval(expr string, args interface{}) (resp *Response, err error)
// Deprecated: the method will be removed in the next major version,
// use an ExecuteRequest object + Do() instead.
Execute(expr string, args interface{}) (resp *Response, err error)

// Deprecated: the method will be removed in the next major version,
// use a SelectRequest object + Do() instead.
GetTyped(space, index interface{}, key interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a SelectRequest object + Do() instead.
SelectTyped(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use an InsertRequest object + Do() instead.
InsertTyped(space interface{}, tuple interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a ReplaceRequest object + Do() instead.
ReplaceTyped(space interface{}, tuple interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a DeleteRequest object + Do() instead.
DeleteTyped(space, index interface{}, key interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a UpdateRequest object + Do() instead.
UpdateTyped(space, index interface{}, key, ops interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a CallRequest object + Do() instead.
CallTyped(functionName string, args interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a Call16Request object + Do() instead.
Call16Typed(functionName string, args interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use a Call17Request object + Do() instead.
Call17Typed(functionName string, args interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use an EvalRequest object + Do() instead.
EvalTyped(expr string, args interface{}, result interface{}) (err error)
// Deprecated: the method will be removed in the next major version,
// use an ExecuteRequest object + Do() instead.
ExecuteTyped(expr string, args interface{}, result interface{}) (SQLInfo, []ColumnMetaData, error)

// Deprecated: the method will be removed in the next major version,
// use a SelectRequest object + Do() instead.
SelectAsync(space, index interface{}, offset, limit uint32, iterator Iter, key interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use an InsertRequest object + Do() instead.
InsertAsync(space interface{}, tuple interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a ReplaceRequest object + Do() instead.
ReplaceAsync(space interface{}, tuple interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a DeleteRequest object + Do() instead.
DeleteAsync(space, index interface{}, key interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a UpdateRequest object + Do() instead.
UpdateAsync(space, index interface{}, key, ops interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a UpsertRequest object + Do() instead.
UpsertAsync(space interface{}, tuple interface{}, ops interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a CallRequest object + Do() instead.
CallAsync(functionName string, args interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a Call16Request object + Do() instead.
Call16Async(functionName string, args interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use a Call17Request object + Do() instead.
Call17Async(functionName string, args interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use an EvalRequest object + Do() instead.
EvalAsync(expr string, args interface{}) *Future
// Deprecated: the method will be removed in the next major version,
// use an ExecuteRequest object + Do() instead.
ExecuteAsync(expr string, args interface{}) *Future

NewPrepared(expr string) (*Prepared, error)
NewStream() (*Stream, error)
NewWatcher(key string, callback WatchCallback) (Watcher, error)

Do(req Request) (fut *Future)
}
28 changes: 21 additions & 7 deletions crud/tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ func TestCrudGenerateData(t *testing.T) {
for _, testCase := range testGenerateDataCases {
t.Run(testCase.name, func(t *testing.T) {
for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}

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

for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}
})
}
Expand All @@ -516,7 +520,9 @@ func TestCrudProcessData(t *testing.T) {
testCrudRequestCheck(t, testCase.req, resp,
err, testCase.expectedRespLen)
for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}
})
}
Expand Down Expand Up @@ -648,7 +654,9 @@ func TestBoolResult(t *testing.T) {
}

for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}
}

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

for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}
}

Expand Down Expand Up @@ -714,7 +724,9 @@ func TestBaseResult(t *testing.T) {
}

for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}
}

Expand Down Expand Up @@ -757,7 +769,9 @@ func TestManyResult(t *testing.T) {
}

for i := 1010; i < 1020; i++ {
conn.Delete(spaceName, nil, []interface{}{uint(i)})
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
}
}

Expand Down
Loading

0 comments on commit 337ca73

Please sign in to comment.