-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(snowflake): extend Entity class to support snowflakes #56795
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
base: master
Are you sure you want to change the base?
Conversation
CarlSchwan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Llike the Id :)
|
We should rename IGenerator and IDecoder to ISnowflakeGenerator and ISnowflakeDecoder, otherwise after a use all code is ambiguous. |
Added |
Altahrim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we introduce a Snowflake DTO, I think Decoder should return it directly
|
Would it make sense to cache the decoded snowflake ID? Seems like there's quite a few expensive calculations going on. |
|
We can still add a cache later if needed but decoding on 64 bits mainly involve binary operations, it should be fast. |
83d0781 to
7d1ded5
Compare
come-nc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also be on the "public readonly properties" team, but that’s bikeshedding.
7d1ded5 to
75a21de
Compare
Altahrim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With same comment than Côme :)
provokateurin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes would be nice. Also I would prefer if the changes were done in multiple commits. I also noticed the name of the DI variable is inconsistent, maybe you can fix that as well.
- [ ] needs nextcloud/server#56795 - [ ] needs #16508 Skipping CI for now, amend the commit message and remove the skip-ci param when ready to rebase and merge [skip-ci] Signed-off-by: Anna Larch <anna@nextcloud.com>
75a21de to
8d35e95
Compare
- [ ] needs nextcloud/server#56795 - [ ] needs #16508 Skipping CI for now, amend the commit message and remove the skip-ci param when ready to rebase and merge [skip ci] Signed-off-by: Anna Larch <anna@nextcloud.com>
and introduce the Snowflake DTO Signed-off-by: Anna Larch <anna@nextcloud.com>
Signed-off-by: Anna Larch <anna@nextcloud.com>
…e the Snowflake DTO
…e the Snowflake DTO
Signed-off-by: Anna Larch <anna@nextcloud.com>
ba2f797 to
67b168a
Compare
| $this->id = Server::get(ISnowflakeGenerator::class)->nextId(); | ||
| $this->markFieldUpdated('id'); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a getId method which returns a string. We can't relly on the one from Entity as it returns an int and this will break on 32 bits system
RFC: extending the Entity class to support snowflake IDs automagically
Good ides - yes / no?
Benefits:
SnowflakeAwareEntityinstead of the regularEntitycreatedAt,setId, and anything else we would like to offer separatelyDrawbacks:
TODO
Checklist
3. to review, feature component)stable32)