- Major changes
- Main package
- datetime package
- decimal package
- multi package
- pool package
- crud package
- test_helpers package
- The
go_tarantool_call_17
build tag is no longer needed, since by default theCallRequest
isCall17Request
. - The
go_tarantool_msgpack_v5
build tag is no longer needed, since only themsgpack/v5
library is used. - The
go_tarantool_ssl_disable
build tag is no longer needed, since the connector is no longer depends onOpenSSL
by default. You could use the external library go-tlsdialer to create a connection with thessl
transport. - Required Go version is
1.20
now. - The
Connect
function became more flexible. It now allows to create a connection with cancellation and a customDialer
implementation. - It is required to use
Request
implementation types with theConnection.Do
method instead ofConnection.<Request>
methods. - The
connection_pool
package 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/v2/datetime"
_ "github.com/tarantool/go-tarantool/v2/decimal"
_ "github.com/tarantool/go-tarantool/v2/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/v2"
_ "github.com/tarantool/go-tarantool/v2/datetime"
_ "github.com/tarantool/go-tarantool/v2/decimal"
_ "github.com/tarantool/go-tarantool/v2/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.
PushCode
constant is removed. To check whether the current response is a push response, useIsPush()
method of the response iterator instead.ErrorNo
constant 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() uint32
replaced by theType() iproto.Type
. Response
method added to theRequest
interface.
- Requests
Update
,UpdateAsync
,UpdateTyped
,Upsert
,UpsertAsync
no longer acceptops
argument (operations) as aninterface{}
.*Operations
needs to be passed instead. Op
struct for update operations made private.- Removed
OpSplice
struct. Operations.Splice
method now accepts 5 arguments instead of 3.UpdateRequest
andUpsertRequest
structs no longer acceptinterface{}
for anops
field.*Operations
needs to be used instead.
Response
is now an interface.- Response header stored in a new
Header
struct. It could be accessed viaHeader()
method.
ResponseIterator
interface 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
Response
interface.SelectResponse
,PrepareResponse
,ExecuteResponse
,PushResponse
are 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
Get
now returns response data instead of the actual response. - New method
GetResponse
added to get an actual response. Future
constructors now acceptRequest
as their argument.- Methods
AppendPush
andSetResponse
accepts responseHeader
and data as their arguments. - Method
Err
was removed because it was causing improper error handling. You need to check an error fromGet
,GetTyped
orGetResponse
with an addition check of a valueResponse.Header().Error
, seeExampleErrorNo
.
- Operations
Ping
,Select
,Insert
,Replace
,Delete
,Update
,Upsert
,Call
,Call16
,Call17
,Eval
,Execute
of aConnector
return response data instead of an actual responses. - New interface
Doer
is added as a child-interface instead of aDo
method.
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
Schema
field from theConnection
struct. Instead, newGetSchema(Doer)
function was added to get the actual connection schema on demand. OverrideSchema(*Schema)
method replaced with theSetSchema(Schema)
.
iproto.Feature
type used instead ofProtocolFeature
.iproto.IPROTO_FEATURE_
constants used instead of local ones.
ResolveSpaceIndex
function forSchemaResolver
interface split into two:ResolveSpace
andResolveIndex
.NamesUseSupported
function added into the interface to get information if the usage of space and index names in requests is supported.Schema
structure no longer implementsSchemaResolver
interface.Spaces
andSpacesById
fields of theSchema
struct store spaces by value.Fields
andFieldsById
fields of theSpace
struct store fields by value.Index
andIndexById
fields of theSpace
struct store indexes by value.Fields
field of theIndex
struct storeIndexField
by 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_pool
subpackage has been renamed topool
. - The type
PoolOpts
has been renamed toOpts
. pool.Connect
andpool.ConnectWithOpts
now 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.Connect
andpool.ConnectWithOpts
now accept[]pool.Instance
as the second argument instead of a list of addresses. Each instance is associated with a unique string name,Dialer
and connection options which allows instances to be independently configured.pool.Connect
,pool.ConnectWithOpts
andpool.Add
add instances into the pool even it is unable to connect to it. The pool will try to connect to the instance later.pool.Add
now accepts context as the first argument, which user may cancel in process.pool.Add
now acceptspool.Instance
as the second argument instead of an address, it allows to configure a new instance more flexible.pool.GetPoolInfo
has been renamed topool.GetInfo
. Return type has been changed tomap[string]ConnectionInfo
.- Operations
Ping
,Select
,Insert
,Replace
,Delete
,Update
,Upsert
,Call
,Call16
,Call17
,Eval
,Execute
of aPooler
return response data instead of an actual responses.
crud
operationsTimeout
option hascrud.OptFloat64
type instead ofcrud.OptUint
.- A slice of a custom type could be used as tuples for
ReplaceManyRequest
andInsertManyRequest
,ReplaceObjectManyRequest
. - A slice of a custom type could be used as objects for
ReplaceObjectManyRequest
andInsertObjectManyRequest
.
- Renamed
StrangerResponse
toMockResponse
.