add idForTimestamp() - #86
Conversation
Added methods to set and get a time resolver.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #86 +/- ##
============================================
+ Coverage 98.71% 98.79% +0.07%
- Complexity 91 98 +7
============================================
Files 7 8 +1
Lines 234 248 +14
============================================
+ Hits 231 245 +14
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds support for injecting a custom “current time” resolver into Snowflake so callers can generate IDs based on historical timestamps (e.g., DB created_at) instead of wall-clock time.
Changes:
- Introduces an optional
Closuretime resolver with setter/getter onSnowflake. - Updates
getCurrentMillisecond()to use the injected resolver when present. - Adds a PHPUnit test validating resolver injection and timestamp encoding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/Snowflake.php | Adds configurable time resolver and wires it into current-time computation. |
| tests/SnowflakeTest.php | Adds unit test covering the new time resolver behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
godruoyi
left a comment
There was a problem hiding this comment.
thanks for your PR @cosmastech i love it, just left a two nit comments,
|
Let me know if this is what you had in mind @godruoyi 🙇 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
godruoyi
left a comment
There was a problem hiding this comment.
Thanks for your quick update. This change looks great and all LGT. Its waiting for the AI to review again.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@cosmastech Released in https://github.com/godruoyi/php-snowflake/releases/tag/3.2.3, Please give it a try and let me know if you run into any issues. |
My team is working on back-filling snowflake IDs for a number of database records. It would be really nice to be able to pull the DB record's
created_attimestamp and use that when generating the historic Snowflake IDs.