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

feat: add p/uuid #2076

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

feat: add p/uuid #2076

wants to merge 4 commits into from

Conversation

DIGIX666
Copy link
Contributor

I suggest adding a UUID package because I think it could be useful to have it available. I think it can further facilitate traceability and compatibility between different systems and apps as they would have a common standard for identifying entities.

To improve UUID generation, I wanted to add a resolver like Snowflake, but from what I've searched, sync/atomic is not supported on Gno. Is there another similar package that I might have missed ?

@DIGIX666 DIGIX666 requested review from a team as code owners May 12, 2024 15:39
@DIGIX666 DIGIX666 requested review from harry-hov and piux2 and removed request for a team May 12, 2024 15:39
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label May 12, 2024
Copy link

codecov bot commented May 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.96%. Comparing base (abaf103) to head (c0b93f0).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2076      +/-   ##
==========================================
- Coverage   54.96%   54.96%   -0.01%     
==========================================
  Files         481      481              
  Lines       67407    67407              
==========================================
- Hits        37052    37049       -3     
- Misses      27336    27337       +1     
- Partials     3019     3021       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DIGIX666 DIGIX666 changed the title feat: initial p/uuid dapp feat: add p/uuid May 12, 2024
@notJoon
Copy link
Member

notJoon commented May 13, 2024

To improve UUID generation, I wanted to add a resolver like Snowflake, but from what I've searched, sync/atomic is not supported on Gno. Is there another similar package that I might have missed ?

There is no other way to guarantee atomicity besides using time in environments where atomic is not supported. If we consider it further, it seems possible to generate a random value (using crypto/rand or not merged yet, but maybe later) like a machine ID, assign it, and then combine it. Of course, this is slightly different from the implementation of Snowflake.

sequence uint16 = 0
StartTime = time.Date(2008, 11, 10, 23, 0, 0, 0, time.UTC)
LastTimestamp int64 = 0
LastSequence uint32 = 0
Copy link
Member

Choose a reason for hiding this comment

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

It seeme like LastSequence does not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I had forgotten to remove it after my tests for the resolver. Thanks

"gno.land/p/demo/ufmt"
)

// TestNextID vérifie la génération correcte des IDs Snowflake.
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to leave the comments in English

@DIGIX666
Copy link
Contributor Author

To improve UUID generation, I wanted to add a resolver like Snowflake, but from what I've searched, sync/atomic is not supported on Gno. Is there another similar package that I might have missed ?

There is no other way to guarantee atomicity besides using time in environments where atomic is not supported. If we consider it further, it seems possible to generate a random value (using crypto/rand or not merged yet, but #1933 later) like a machine ID, assign it, and then combine it. Of course, this is slightly different from the implementation of Snowflake.

Thanks for your explanation. I will check the progress of crypto/rand to try to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

2 participants