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: custom snowflake epoch, various fixes #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

shayypy
Copy link

@shayypy shayypy commented Apr 4, 2024

Hello, I'm using this package to generate Snowflakes but I wanted to set a custom epoch that makes more sense for my project (I'll never have an ID from 1970-2023, so why bother keeping those 53 redundant years?).

At first I attempted to override Snowflake.EPOCH but this was not working for me in my environment (i.e. snowflakes with the same epoch were generated), and the readme seemed to imply that this parameter should be passed through generate anyway. I also added an epoch parameter to parse so that timestamps with a custom epoch can be parsed correctly.

Unrelated changes that are also in this pull:

  • build package (there were apparently some standing unbuilt changes)
  • add docs for shard_id option on generate
  • fix isValid only accepting ids with length 19
    • snowflakes are of course generated with timestamps, so they get longer with time. my snowflake generated 4 months after its epoch was only 17 digits long, and new twitter snowflakes are 19, but I went to 22 as a cautionary measure (feel free to change)
  • fix incorrectly named shift (start) parameter in doc

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.

1 participant