Skip to content

Support UUID type in msgpack #104

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
Nov 26, 2021
Merged

Support UUID type in msgpack #104

merged 1 commit into from
Nov 26, 2021

Conversation

DifferentialOrange
Copy link
Member

@DifferentialOrange DifferentialOrange commented Oct 29, 2021

This patch provides UUID support for all space operations and as function return result. UUID type was introduced in Tarantool 2.4.1. See more in commit messages.

To use UUID with google/uuid in msgpack, import tarantool/go-tarantool/uuid submodule.

package main

import (
	"log"
	"time"

	"github.com/tarantool/go-tarantool"
	_ "github.com/tarantool/go-tarantool/uuid"
	"github.com/google/uuid"
)

func main() {
	server := "127.0.0.1:3013"
	opts := tarantool.Opts{
		Timeout:       500 * time.Millisecond,
		Reconnect:     1 * time.Second,
		MaxReconnects: 3,
		User:          "test",
		Pass:          "test",
	}
	client, err := tarantool.Connect(server, opts)
	if err != nil {
		log.Fatalf("Failed to connect: %s", err.Error())
	}

	spaceNo := uint32(524)
	indexNo := uint32(0)

	id, uuidErr := uuid.Parse("c8f0fa1f-da29-438c-a040-393f1126ad39")
	if uuidErr != nil {
		t.Errorf("Failed to prepare uuid: %s", uuidErr)
	}

	resp, err := conn.Replace(space, index, 0, 1, IterEq, []interface{}{ id })

	log.Println("UUID tuple replace")
	log.Println("Error", err)
	log.Println("Code", resp.Code)
	log.Println("Data", resp.Data)
}

Closes #90

@DifferentialOrange DifferentialOrange force-pushed the 90-uuid-support branch 3 times, most recently from ed87373 to 67374a5 Compare November 1, 2021 15:02
@DifferentialOrange DifferentialOrange changed the title UUID support Support UUID type in msgpack Nov 1, 2021
@DifferentialOrange DifferentialOrange marked this pull request as ready for review November 1, 2021 15:04
@funny-falcon
Copy link

Could you place it into subfolder (subpackage)? I don't like it in main package.

@DifferentialOrange
Copy link
Member Author

Could you place it into subfolder (subpackage)? I don't like it in main package.

What's the motivation? UUID is built-in in Tarantool.

@funny-falcon
Copy link

What's the motivation? UUID is built-in in Tarantool.

Yep. But it doesn't built-in in Golang.

Why github.com/google/uuid is better than any other?

  • github.com/hashicorp/go-uuid
  • github.com/satori/go.uuid
  • github.com/gofrs/uuid
  • go.mongodb.org/mongo-driver/x/mongo/driver/uuid

Looks like satori's one is more popular than google's one.

@DifferentialOrange
Copy link
Member Author

DifferentialOrange commented Nov 8, 2021

What's the motivation? UUID is built-in in Tarantool.

Yep. But it doesn't built-in in Golang.

Why github.com/google/uuid is better than any other?

* github.com/hashicorp/go-uuid

* github.com/satori/go.uuid

* github.com/gofrs/uuid

* go.mongodb.org/mongo-driver/x/mongo/driver/uuid

Looks like satori's one is more popular than google's one.

Well, I don't think it is better than any other package, but AFAIK it doesn't worse than any of them since they all implement similar basic functionality. Regarding popularity, satori/go.uuid is a bit more popular than google/uuid in terms of GitHub stars (4.4k vs 3.2k), but google/uuid leaves behind satori/go.uuid in case of Used by statistics: 59.1k GitHub repos vs 15.4k with satori/go.uuid. I think the latter is more important. To be honest, I have chosen google/uuid primarly because it is the package that was used by clients that requested UUID support for Tarantool in issue comments, so if you know any reasons why it's better not to use google/uuid or to use any other package, I would be glad to listen since I do not carried out a thorough comparison.

Yeah, if someone is willing to use a Tarantool connector with application that already uses another uuid package, it can introduce a conflict of namespaces. I'll try to rework code to avoid it.

@funny-falcon
Copy link

Yep, I'm not against google/uuid. And I'm not promoting any particular uuid package. I'm against including any particular uuid in main package-folder.

Golang provocates using subpackages (subfolders) for anything optional. And I think it is right way. And dependency on particular uuid package is optional.

@DifferentialOrange
Copy link
Member Author

Moved to submodule in new commit

@ochaton
Copy link
Member

ochaton commented Nov 8, 2021

I've noticed that without importing github.com/tarantool/go-tarantool/uuid connector returns msgpack exception about undefined msg ext=2. This was made intentionally?

@LeonidVas
Copy link

Yep, I'm not against google/uuid. And I'm not promoting any particular uuid package. I'm against including any particular uuid in main package-folder.

Golang provocates using subpackages (subfolders) for anything optional. And I think it is right way. And dependency on particular uuid package is optional.

Hi! Are you suggesting moving the uuid into a subpackage just to decorate the project structure or something else? I don't mind, just interesting.

@LeonidVas
Copy link

Hi! Thank you for the patch. Generally ok.
See several comments bellow:

  • I (and not only) have the habit of watching one patchset commit after another during a review and I see no reason to make changes in the first commit of a patchset and then change them in the next. If a different behavior is adopted in this project, then ok.
  • what for we need a second config.lua in uuid that partially duplicates the config.lua from the root of the project?

@DifferentialOrange
Copy link
Member Author

I've noticed that without importing github.com/tarantool/go-tarantool/uuid connector returns msgpack exception about undefined msg ext=2. This was made intentionally?

Well, since uuid was extracted to submodule after review, you can say that it is intentional, but discussable

@DifferentialOrange
Copy link
Member Author

DifferentialOrange commented Nov 8, 2021

Hi! Thank you for the patch. Generally ok. See several comments bellow:

* I (and not only) have the habit of watching one patchset commit after another during a review and I see no reason to make changes in the first commit of a patchset and then change them in the next. If a different behavior is adopted in this project, then ok.

* what for we need a second `config.lua` in uuid that partially duplicates the `config.lua` from the root of the project?
  • I think I merge two commits into one later. Since there are some debates about using a submodule, it is possible that the last one will be reverted after a discussion, so I did not merged them yet.
  • It is a question about test infrastructure and for now I just mimic an existing one. Running tarantool ./config.lua prepares environment for root folder tests go test . and running tarantool ./uuid/config.lua prepares test environment for go test ./uuid tests. I made it similar to tarantool/multi and tarantool/queue tests.

Copy link

@LeonidVas LeonidVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I am not very familiar with the project and the rules for formatting the code and commits in it, so I could not take into account some points

@DifferentialOrange DifferentialOrange force-pushed the 90-uuid-support branch 2 times, most recently from 536e750 to 68a6b1c Compare November 15, 2021 07:39
Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to squash commits (it seems worthful)? Shouldn't we drop github.com/google/uuid from go.mod in the second commit (and move it to go.mod inside uuid/)? Or it does not work this way?

I have a couple of questions, but generally can't add a value here. LGTM, but my review is unsufficient.

@DifferentialOrange
Copy link
Member Author

DifferentialOrange commented Nov 24, 2021

Do you plan to squash commits (it seems worthful)?

Yes, I changed it in a last force-push.

Shouldn't we drop github.com/google/uuid from go.mod in the second commit (and move it to go.mod inside uuid/)?

Thank you, it definitely should be like this. Fixed.

This patch provides UUID support for all space operations and as
function return result. UUID type was introduced in Tarantool 2.4.1.
See more in commit messages [1].

To use UUID with google/uuid in msgpack, import
tarantool/go-tarantool/uuid submodule.

1. tarantool/tarantool@d68fc29

Closes #90
Copy link

@funny-falcon funny-falcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think go.mod changes a necessary. But nonetheless, approve.

@funny-falcon funny-falcon merged commit 4c78e0a into master Nov 26, 2021
@Totktonada Totktonada deleted the 90-uuid-support branch December 13, 2021 08:37
This was referenced Dec 23, 2021
DifferentialOrange added a commit that referenced this pull request Jan 13, 2022
After moving UUID-related code (including tests) in PR #104
to separate folder, test setup of UUID space was remained in
main folder config.lua by mistake. This patch removes it.

Closes #128
DifferentialOrange added a commit that referenced this pull request Jan 13, 2022
After moving UUID-related code (including tests) in PR #104
to separate folder, test setup of UUID space was remained in
main folder config.lua by mistake. This patch removes it.

Closes #128
ligurio pushed a commit that referenced this pull request Mar 7, 2022
After moving UUID-related code (including tests) in PR #104
to separate folder, test setup of UUID space was remained in
main folder config.lua by mistake. This patch removes it.

Closes #128
ligurio pushed a commit that referenced this pull request Mar 30, 2022
After moving UUID-related code (including tests) in PR #104
to separate folder, test setup of UUID space was remained in
main folder config.lua by mistake. This patch removes it.

Closes #128
ligurio pushed a commit that referenced this pull request Apr 7, 2022
After moving UUID-related code (including tests) in PR #104
to separate folder, test setup of UUID space was remained in
main folder config.lua by mistake. This patch removes it.

Closes #128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there support of built-in UUID type?
5 participants