Skip to content

api: mark all request methods as deprecated #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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