TODO
-
Required Go version is
1.24now. -
box.Newreturns an error instead of panic -
Added
box.MustNewwrapper forbox.Newwithout an error -
Removed deprecated
poolmethods, related interfaces and tests are updated. -
Removed
box.session.push()support: Future.AppendPush() and Future.GetIterator() methods, ResponseIterator and TimeoutResponseIterator types. -
Removed deprecated
Connectionmethods, related interfaces and tests are updated.NOTE: due to Future.GetTyped() doesn't decode SelectRequest into structure, substitute Connection.GetTyped() following the example:
var singleTpl = Tuple{} err = conn.GetTyped(space, index, key, &singleTpl)
At now became:
var tpl []Tuple err = conn.Do(NewSelectRequest(space). Index(index). Limit(1). Key(key) ).GetTyped(&tpl) singleTpl := tpl[0]
-
Future.done replaced with Future.cond (sync.Cond) + Future.finished bool.
-
Futureis an interface now. -
ConnectionPool.Close()returns a single error value, combining multiple errors using errors.Join() -
Future.Release()call could be used to free resources allocated for theFutureobject created by aConnectionobject.
- Major changes
- Main package
- datetime package
- decimal package
- multi package
- pool package
- crud package
- test_helpers package
- The
go_tarantool_call_17build tag is no longer needed, since by default theCallRequestisCall17Request. - The
go_tarantool_msgpack_v5build tag is no longer needed, since only themsgpack/v5library is used. - The
go_tarantool_ssl_disablebuild tag is no longer needed, since the connector is no longer depends onOpenSSLby default. You could use the external library go-tlsdialer to create a connection with thessltransport. - Required Go version is
1.20now. - The
Connectfunction became more flexible. It now allows to create a connection with cancellation and a customDialerimplementation. - It is required to use
Requestimplementation types with theConnection.Domethod instead ofConnection.<Request>methods. - The
connection_poolpackage renamed topool.
The basic code for the v1.12.2 release:
package tarantool
import (
"fmt"
"github.com/tarantool/go-tarantool"
_ "github.com/tarantool/go-tarantool/v3/datetime"
_ "github.com/tarantool/go-tarantool/v3/decimal"
_ "github.com/tarantool/go-tarantool/v3/uuid"
)
func main() {
opts := tarantool.Opts{User: "guest"}
conn, err := tarantool.Connect("127.0.0.1:3301", opts)
if err != nil {
fmt.Println("Connection refused:", err)
return
}
resp, err := conn.Insert(999, []interface{}{99999, "BB"})
if err != nil {
fmt.Println("Error:", err)
fmt.Println("Code:", resp.Code)
} else {
fmt.Println("Data:", resp.Data)
}
}At now became:
package tarantool
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
_ "github.com/tarantool/go-tarantool/v3/datetime"
_ "github.com/tarantool/go-tarantool/v3/decimal"
_ "github.com/tarantool/go-tarantool/v3/uuid"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
dialer := tarantool.NetDialer{
Address: "127.0.0.1:3301",
User: "guest",
}
opts := tarantool.Opts{
Timeout: time.Second,
}
conn, err := tarantool.Connect(ctx, dialer, opts)
if err != nil {
fmt.Println("Connection refused:", err)
return
}
data, err := conn.Do(
tarantool.NewInsertRequest(999).Tuple([]interface{}{99999, "BB"})).Get()
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("Data:", data)
}
}Required Go version is updated from 1.13 to 1.20.
At now the msgpack/v5 library is used for the msgpack encoding/decondig.
Most function names and argument types in msgpack/v5 and msgpack.v2
have not changed (in our code, we noticed changes in EncodeInt, EncodeUint
and RegisterExt). But there are a lot of changes in a logic of encoding and
decoding. On the plus side the migration seems easy, but on the minus side you
need to be very careful.
First of all, EncodeInt8, EncodeInt16, EncodeInt32, EncodeInt64
and EncodeUint* analogues at msgpack/v5 encode numbers as is without loss of
type. In msgpack.v2 the type of a number is reduced to a value.
Secondly, a base decoding function does not convert numbers to int64 or
uint64. It converts numbers to an exact type defined by MessagePack. The
change makes manual type conversions much more difficult and can lead to
runtime errors with an old code. We do not recommend to use type conversions
and give preference to *Typed functions (besides, it's faster).
There are also changes in the logic that can lead to errors in the old code,
as example. Although in
msgpack/v5 some functions for the logic tuning were added (see
UseLooseInterfaceDecoding, UseCompactInts etc), it is still impossible
to achieve full compliance of behavior between msgpack/v5 and msgpack.v2.
So we don't go this way. We use standard settings if it possible.
Call requests uses IPROTO_CALL instead of IPROTO_CALL_16.
So now Call = Call17 and NewCallRequest = NewCall17Request. A result
of the requests is an array instead of array of arrays.
- IPROTO constants have been moved to a separate package go-iproto.
PushCodeconstant is removed. To check whether the current response is a push response, useIsPush()method of the response iterator instead.ErrorNoconstant is added to indicate that no error has occurred while getting the response. It should be used instead of the removedOkCode. SeeExampleErrorNo.
- The method
Code() uint32replaced by theType() iproto.Type. Responsemethod added to theRequestinterface.
- Requests
Update,UpdateAsync,UpdateTyped,Upsert,UpsertAsyncno longer acceptopsargument (operations) as aninterface{}.*Operationsneeds to be passed instead. Opstruct for update operations made private.- Removed
OpSplicestruct. Operations.Splicemethod now accepts 5 arguments instead of 3.UpdateRequestandUpsertRequeststructs no longer acceptinterface{}for anopsfield.*Operationsneeds to be used instead.
Responseis now an interface.- Response header stored in a new
Headerstruct. It could be accessed viaHeader()method.
ResponseIteratorinterface now hasIsPush()method. It returns true if the current response is a push response.- For each request type, a different response type is created. They all
implement a
Responseinterface.SelectResponse,PrepareResponse,ExecuteResponse,PushResponseare a part of a public API.Pos(),MetaData(),SQLInfo()methods created for them to get specific info. Special types of responses are used with special requests.
- Method
Getnow returns response data instead of the actual response. - New method
GetResponseadded to get an actual response. Futureconstructors now acceptRequestas their argument.- Methods
AppendPushandSetResponseaccepts responseHeaderand data as their arguments. - Method
Errwas removed because it was causing improper error handling. You need to check an error fromGet,GetTypedorGetResponsewith an addition check of a valueResponse.Header().Error, seeExampleErrorNo.
- Operations
Ping,Select,Insert,Replace,Delete,Update,Upsert,Call,Call16,Call17,Eval,Executeof aConnectorreturn response data instead of an actual responses. - New interface
Doeris added as a child-interface instead of aDomethod.
connection.Connect no longer return non-working connection objects. This
function now does not attempt to reconnect and tries to establish a connection
only once. Function might be canceled via context. Context accepted as first
argument, and user may cancel it in process.
Now you need to pass Dialer as the second argument instead of URI.
If you were using a non-SSL connection, you need to create NetDialer.
For SSL-enabled connections, use OpenSSLDialer from the
go-tlsdialer package.
Please note that the options for creating a connection are now stored in
corresponding Dialer, not in Opts.
- Removed
Schemafield from theConnectionstruct. Instead, newGetSchema(Doer)function was added to get the actual connection schema on demand. OverrideSchema(*Schema)method replaced with theSetSchema(Schema).
iproto.Featuretype used instead ofProtocolFeature.iproto.IPROTO_FEATURE_constants used instead of local ones.
ResolveSpaceIndexfunction forSchemaResolverinterface split into two:ResolveSpaceandResolveIndex.NamesUseSupportedfunction added into the interface to get information if the usage of space and index names in requests is supported.Schemastructure no longer implementsSchemaResolverinterface.SpacesandSpacesByIdfields of theSchemastruct store spaces by value.FieldsandFieldsByIdfields of theSpacestruct store fields by value.IndexandIndexByIdfields of theSpacestruct store indexes by value.Fieldsfield of theIndexstruct storeIndexFieldby value.
Now you need to use objects of the Datetime type instead of pointers to it. A
new constructor MakeDatetime returns an object. NewDatetime has been
removed.
Now you need to use objects of the Decimal type instead of pointers to it. A
new constructor MakeDecimal returns an object. NewDecimal has been removed.
The subpackage has been deleted. You could use pool instead.
- The
connection_poolsubpackage has been renamed topool. - The type
PoolOptshas been renamed toOpts. pool.Connectandpool.ConnectWithOptsnow accept context as the first argument, which user may cancel in process. If it is canceled in progress, an error will be returned and all created connections will be closed.pool.Connectandpool.ConnectWithOptsnow accept[]pool.Instanceas the second argument instead of a list of addresses. Each instance is associated with a unique string name,Dialerand connection options which allows instances to be independently configured.pool.Connect,pool.ConnectWithOptsandpool.Addadd instances into the pool even it is unable to connect to it. The pool will try to connect to the instance later.pool.Addnow accepts context as the first argument, which user may cancel in process.pool.Addnow acceptspool.Instanceas the second argument instead of an address, it allows to configure a new instance more flexible.pool.GetPoolInfohas been renamed topool.GetInfo. Return type has been changed tomap[string]ConnectionInfo.- Operations
Ping,Select,Insert,Replace,Delete,Update,Upsert,Call,Call16,Call17,Eval,Executeof aPoolerreturn response data instead of an actual responses.
crudoperationsTimeoutoption hascrud.OptFloat64type instead ofcrud.OptUint.- A slice of a custom type could be used as tuples for
ReplaceManyRequestandInsertManyRequest,ReplaceObjectManyRequest. - A slice of a custom type could be used as objects for
ReplaceObjectManyRequestandInsertObjectManyRequest.
- Renamed
StrangerResponsetoMockResponse.