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

This PR adds UUID builder for uprotocol uuidv8 #151

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

BishrutSubedi
Copy link
Contributor

@BishrutSubedi BishrutSubedi commented Jun 11, 2024

Add uuid builder and it's unit test

TODO:

Convert from uuidv8 to uuidv7
Follow up on thread safety

@BishrutSubedi BishrutSubedi marked this pull request as ready for review June 11, 2024 06:20
@gregmedd gregmedd self-requested a review June 12, 2024 02:33
@gregmedd gregmedd linked an issue Jun 12, 2024 that may be closed by this pull request
Copy link
Contributor

@gregmedd gregmedd left a comment

Choose a reason for hiding this comment

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

For the most part, this looks good to me. There are a few changes that could clean this up, and I think that the current implementation doesn't actually share state between instances.

include/up-cpp/datamodel/builder/Uuid.h Outdated Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Outdated Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Outdated Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Outdated Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Outdated Show resolved Hide resolved
test/coverage/datamodel/UuidBuilderTest.cpp Show resolved Hide resolved
test/coverage/datamodel/UuidBuilderTest.cpp Show resolved Hide resolved
@stevenhartley
Copy link

that could clean this up, and I think that the current

@gregmedd given the change now to move to UUIDv7 for the next release, we don't need to share state anymore as rand_a and rand_b is re-generated at each call to create()

src/datamodel/builder/Uuid.cpp Outdated Show resolved Hide resolved
src/datamodel/builder/Uuid.cpp Outdated Show resolved Hide resolved
@billpittman
Copy link
Contributor

Looking at the code and RFC 9562 (referenced in the spec), this looks more like v7 instead of v8. Is the title a typo ?

If this is supposed to be v8, it seems like all the variable names are aligning with the v7 field names instead of the v8 field names (ie unix_ts_ms vs custom_a, etc.).

@BishrutSubedi
Copy link
Contributor Author

BishrutSubedi commented Jun 12, 2024

Looking at the code and RFC 9562 (referenced in the spec), this looks more like v7 instead of v8. Is the title a typo ?

If this is supposed to be v8, it seems like all the variable names are aligning with the v7 field names instead of the v8 field names (ie unix_ts_ms vs custom_a, etc.).

The spec were recently updated to use uuidv7. The previous spec of uuidv8 closely aligned with uuidv7. The implementation should be similar. I'll go over spec to see if there are any specific changes

@gregmedd
Copy link
Contributor

On the change from v8 to v7, I lean towards proceeding with this PR as-is. I understand it is the wrong UUID version. We can take a follow-up task to correct the implementation back to uuid v7 and evaluate if any of the other modules need to change at the same time (e.g. the validator).

@BishrutSubedi
Copy link
Contributor Author

BishrutSubedi commented Jun 12, 2024

It looks like the counter field is replaced by rand_a. The remaining bits allocation are similar.

@gregmedd
Copy link
Contributor

Tracking change to UUIDv7 as #156

TODO:
1. Follow up with uuidv7 for clean up and new spec
2. Thread safety on shared state
@BishrutSubedi
Copy link
Contributor Author

BishrutSubedi commented Jun 13, 2024

In addition to what @gregmedd said above, it seems to me if the counter freezees, shouldn't that be some sort of error? If someone generates 5000 UUID's within one ms (possible I think), some of them would be identical ... right?

@billpittman I agree with this, but strictly going by the previous spec, counter is expected to freeze. This is a valid point though. I think throwing exception here can cause software calling build() function to crash, unless they check the counter value and handle it appropriately. May be returning std:nullopt would be better than raising exception. We're looking to change this to v7, but this is good discussion to have soon

Copy link
Contributor

@gregmedd gregmedd left a comment

Choose a reason for hiding this comment

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

LGTM. UUIDv7 will be implemented as a follow-up (#156)

@gregmedd gregmedd merged commit dbd3159 into eclipse-uprotocol:main Jun 18, 2024
5 checks passed
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.

Implement and test datamodel::builder::Uuid
4 participants