Skip to content
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

v2 begins #251

Merged
merged 12 commits into from
Jun 7, 2023
57 changes: 0 additions & 57 deletions .github/workflows/testing.yml
DifferentialOrange marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,6 @@ jobs:
make test
make testrace

- name: Run regression tests with call_17
run: |
make test TAGS="go_tarantool_call_17"
make testrace TAGS="go_tarantool_call_17"

- name: Run regression tests with msgpack.v5
run: |
make test TAGS="go_tarantool_msgpack_v5"
make testrace TAGS="go_tarantool_msgpack_v5"

- name: Run regression tests with msgpack.v5 and call_17
run: |
make test TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"
make testrace TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"

- name: Run fuzzing tests
if: ${{ matrix.fuzzing }}
run: make fuzzing TAGS="go_tarantool_decimal_fuzzing"
Expand Down Expand Up @@ -199,30 +184,6 @@ jobs:
env:
TEST_TNT_SSL: ${{matrix.ssl}}

- name: Run regression tests with call_17
run: |
source tarantool-enterprise/env.sh
make test TAGS="go_tarantool_call_17"
make testrace TAGS="go_tarantool_call_17"
env:
TEST_TNT_SSL: ${{matrix.ssl}}

- name: Run regression tests with msgpack.v5
run: |
source tarantool-enterprise/env.sh
make test TAGS="go_tarantool_msgpack_v5"
make testrace TAGS="go_tarantool_msgpack_v5"
env:
TEST_TNT_SSL: ${{matrix.ssl}}

- name: Run regression tests with msgpack.v5 and call_17
run: |
source tarantool-enterprise/env.sh
make test TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"
make testrace TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"
env:
TEST_TNT_SSL: ${{matrix.ssl}}

- name: Run fuzzing tests
if: ${{ matrix.fuzzing }}
run: make fuzzing TAGS="go_tarantool_decimal_fuzzing"
Expand Down Expand Up @@ -389,24 +350,6 @@ jobs:
make test
make testrace

- name: Run regression tests with call_17
run: |
cd "${SRCDIR}"
make test TAGS="go_tarantool_call_17"
make testrace TAGS="go_tarantool_call_17"

- name: Run regression tests with msgpack.v5
run: |
cd "${SRCDIR}"
make test TAGS="go_tarantool_msgpack_v5"
make testrace TAGS="go_tarantool_msgpack_v5"

- name: Run regression tests with msgpack.v5 and call_17
run: |
cd "${SRCDIR}"
make test TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"
make testrace TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"

- name: Run fuzzing tests
if: ${{ matrix.fuzzing }}
run: |
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,25 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.

### Added

- Type() method to the Request interface (#158)
- Enumeration types for RLimitAction/iterators (#158)
DifferentialOrange marked this conversation as resolved.
Show resolved Hide resolved

### Changed

- connection_pool renamed to pool (#239)
- Use msgpack/v5 instead of msgpack.v2 (#236)
- Call/NewCallRequest = Call17/NewCall17Request (#235)

### Removed

- multi subpackage (#240)
- msgpack.v2 support (#236)
- pool/RoundRobinStrategy (#158)
- DeadlineIO (#158)
- UUID_extId (#158)
- IPROTO constants (#158)
- Code() method from the Request interface (#158)

### Fixed

## [1.12.0] - 2023-06-07
Expand Down
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ testrace:
go clean -testcache
go test -race -tags "$(TAGS)" ./... -v -p 1

.PHONY: test-connection-pool
test-connection-pool:
@echo "Running tests in connection_pool package"
.PHONY: test-pool
test-pool:
@echo "Running tests in pool package"
go clean -testcache
go test -tags "$(TAGS)" ./connection_pool/ -v -p 1
go test -tags "$(TAGS)" ./pool/ -v -p 1

.PHONY: test-datetime
test-datetime:
Expand All @@ -75,12 +75,6 @@ test-decimal:
go clean -testcache
go test -tags "$(TAGS)" ./decimal/ -v -p 1

.PHONY: test-multi
test-multi:
@echo "Running tests in multiconnection package"
go clean -testcache
go test -tags "$(TAGS)" ./multi/ -v -p 1

.PHONY: test-queue
test-queue:
@echo "Running tests in queue package"
Expand Down
62 changes: 42 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ faster than other packages according to public benchmarks.
* [Documentation](#documentation)
* [API reference](#api-reference)
* [Walking\-through example](#walking-through-example)
* [msgpack.v5 migration](#msgpackv5-migration)
* [Migration to v2](#migration-to-v2)
* [multi package](#multi-package)
* [pool package](#pool-package)
* [msgpack.v5](#msgpackv5)
* [Call = Call17](#call--call17)
* [IPROTO constants](#iproto-constants)
* [Request interface](#request-interface)
* [Contributing](#contributing)
* [Alternative connectors](#alternative-connectors)

Expand All @@ -45,7 +51,7 @@ The package `go-tarantool` is located in [tarantool/go-tarantool][go-tarantool]
repository. To download and install, say:

```
$ go get github.com/tarantool/go-tarantool
$ go get github.com/tarantool/go-tarantool/v2
```

This should put the source and binary files in subdirectories of
Expand All @@ -63,21 +69,7 @@ This allows us to introduce new features without losing backward compatibility.
```
go_tarantool_ssl_disable
```
2. To change the default `Call` behavior from `Call16` to `Call17`, you can use
the build tag:
```
go_tarantool_call_17
```
**Note:** In future releases, `Call17` may be used as default `Call` behavior.
3. To replace usage of `msgpack.v2` with `msgpack.v5`, you can use the build
tag:
```
go_tarantool_msgpack_v5
```
**Note:** In future releases, `msgpack.v5` may be used by default. We recommend
to read [msgpack.v5 migration notes](#msgpackv5-migration) and try to
use msgpack.v5 before the changes.
4. To run fuzz tests with decimals, you can use the build tag:
2. To run fuzz tests with decimals, you can use the build tag:
```
go_tarantool_decimal_fuzzing
```
Expand Down Expand Up @@ -112,7 +104,7 @@ package tarantool

import (
"fmt"
"github.com/tarantool/go-tarantool"
"github.com/tarantool/go-tarantool/v2"
)

func main() {
Expand All @@ -129,7 +121,7 @@ func main() {
}
```

**Observation 1:** The line "`github.com/tarantool/go-tarantool`" in the
**Observation 1:** The line "`github.com/tarantool/go-tarantool/v2`" in the
`import(...)` section brings in all Tarantool-related functions and structures.

**Observation 2:** The line starting with "`Opts :=`" sets up the options for
Expand All @@ -153,7 +145,22 @@ There are two parameters:
* a space number (it could just as easily have been a space name), and
* a tuple.

### msgpack.v5 migration
### Migration to v2

The article describes migration from go-tarantool to go-tarantool/v2.

#### multi package

The subpackage has been deleted. You could use `pool` instead.

#### pool package

The logic has not changed, but there are a few renames:

* The `connection_pool` subpackage has been renamed to `pool`.
* The type `PoolOpts` has been renamed to `Opts`.

#### msgpack.v5

Most function names and argument types in `msgpack.v5` and `msgpack.v2`
have not changed (in our code, we noticed changes in `EncodeInt`, `EncodeUint`
Expand All @@ -178,6 +185,21 @@ There are also changes in the logic that can lead to errors in the old code,
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 = Call17

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

IPROTO constants have been moved to a separate package [go-iproto](https://github.com/tarantool/go-iproto).

#### Request interface

* The method `Code() uint32` replaced by the `Type() iproto.Type`.

## Contributing

See [the contributing guide](CONTRIBUTING.md) for detailed instructions on how
Expand Down
2 changes: 1 addition & 1 deletion auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
. "github.com/tarantool/go-tarantool"
. "github.com/tarantool/go-tarantool/v2"
)

func TestAuth_String(t *testing.T) {
Expand Down
30 changes: 18 additions & 12 deletions box_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tarantool
import (
"bytes"
"fmt"

"github.com/vmihailenco/msgpack/v5"
)

const errorExtID = 3
Expand Down Expand Up @@ -69,7 +71,7 @@ func (e *BoxError) Depth() int {
return depth
}

func decodeBoxError(d *decoder) (*BoxError, error) {
func decodeBoxError(d *msgpack.Decoder) (*BoxError, error) {
var l, larr, l1, l2 int
var errorStack []BoxError
var err error
Expand Down Expand Up @@ -169,15 +171,15 @@ func decodeBoxError(d *decoder) (*BoxError, error) {
return &errorStack[0], nil
}

func encodeBoxError(enc *encoder, boxError *BoxError) error {
func encodeBoxError(enc *msgpack.Encoder, boxError *BoxError) error {
if boxError == nil {
return fmt.Errorf("msgpack: unexpected nil BoxError on encode")
}

if err := enc.EncodeMapLen(1); err != nil {
return err
}
if err := encodeUint(enc, keyErrorStack); err != nil {
if err := enc.EncodeUint(keyErrorStack); err != nil {
return err
}

Expand All @@ -199,50 +201,50 @@ func encodeBoxError(enc *encoder, boxError *BoxError) error {
}
}

if err := encodeUint(enc, keyErrorType); err != nil {
if err := enc.EncodeUint(keyErrorType); err != nil {
return err
}
if err := enc.EncodeString(boxError.Type); err != nil {
return err
}

if err := encodeUint(enc, keyErrorFile); err != nil {
if err := enc.EncodeUint(keyErrorFile); err != nil {
return err
}
if err := enc.EncodeString(boxError.File); err != nil {
return err
}

if err := encodeUint(enc, keyErrorLine); err != nil {
if err := enc.EncodeUint(keyErrorLine); err != nil {
return err
}
if err := enc.EncodeUint64(boxError.Line); err != nil {
return err
}

if err := encodeUint(enc, keyErrorMessage); err != nil {
if err := enc.EncodeUint(keyErrorMessage); err != nil {
return err
}
if err := enc.EncodeString(boxError.Msg); err != nil {
return err
}

if err := encodeUint(enc, keyErrorErrno); err != nil {
if err := enc.EncodeUint(keyErrorErrno); err != nil {
return err
}
if err := enc.EncodeUint64(boxError.Errno); err != nil {
return err
}

if err := encodeUint(enc, keyErrorErrcode); err != nil {
if err := enc.EncodeUint(keyErrorErrcode); err != nil {
return err
}
if err := enc.EncodeUint64(boxError.Code); err != nil {
return err
}

if fieldsLen > 0 {
if err := encodeUint(enc, keyErrorFields); err != nil {
if err := enc.EncodeUint(keyErrorFields); err != nil {
return err
}

Expand Down Expand Up @@ -276,7 +278,7 @@ func (e *BoxError) UnmarshalMsgpack(b []byte) error {
}

buf := bytes.NewBuffer(b)
dec := newDecoder(buf)
dec := msgpack.NewDecoder(buf)

if val, err := decodeBoxError(dec); err != nil {
return err
Expand All @@ -290,10 +292,14 @@ func (e *BoxError) UnmarshalMsgpack(b []byte) error {
func (e *BoxError) MarshalMsgpack() ([]byte, error) {
var buf bytes.Buffer

enc := newEncoder(&buf)
enc := msgpack.NewEncoder(&buf)
if err := encodeBoxError(enc, e); err != nil {
return nil, err
}

return buf.Bytes(), nil
}

func init() {
msgpack.RegisterExt(errorExtID, (*BoxError)(nil))
}
Loading