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

CP-34028: implement Uuid with Uuidm #103

Closed
wants to merge 5 commits into from

Conversation

psafont
Copy link
Member

@psafont psafont commented Apr 8, 2021

The Uuid module is problematic because it doesn't parse input at all. This PR tries to do a better job at that and replaces its base type from string to Uuidm, which should make the representation more compact when used.

In order to guard from guard values it's necessary to change the interface to use Option: using exceptions would be dangerous and some uses might be missed and lead to unhandled exceptions.

Draft PR as it has a breaking change so clients need to be modified first; I would like some feedback before doing that.

TODO: The functions that generate random UUID do not use the ones provided by Uuidm. I don't think the Option.get is worrying because previously a different exception would have been raised, but there's a chance to make it more robust.

Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

Looks good!

Also adds a pretty_printer and an equal function

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Change signature functions that generate UUIDs from inputs to return a
UUID as an option. They now transform the input to make sure the
resulting string is a valid UUID.

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Also reorganized the functions and signatures to group similar
functionality together.

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
It's useful to extract uuid from hashed bytes

Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
@psafont
Copy link
Member Author

psafont commented Jun 14, 2021

While having the phantom type makes sense to avoid comparing uuid of different types of resources, xapi needs to have a dedicated type to model uuids instead of using strings.

On top of this, using Uuid.t means that for every roundtrip we're paying the cost of converting from the string representation to the raw byte value and viceversa which may impact performance, having the string representation with the new interface may be more desirable.

@psafont
Copy link
Member Author

psafont commented Sep 22, 2021

Obsoleted by the xapi PR

@psafont psafont closed this Sep 22, 2021
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.

2 participants