{"id":18765846,"url":"https://github.com/yeqown/snowflake","last_synced_at":"2025-12-08T06:30:17.403Z","repository":{"id":57561810,"uuid":"178980235","full_name":"yeqown/snowflake","owner":"yeqown","description":"twitter's global ID generator alg implementation based c, and it provide extension for lua and CLI program.","archived":false,"fork":false,"pushed_at":"2023-08-25T01:57:29.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-29T06:12:34.529Z","etag":null,"topics":["c","cli","cmake","library","lua","shared-library","static-library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeqown.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-02T02:07:11.000Z","updated_at":"2023-08-24T14:27:33.000Z","dependencies_parsed_at":"2024-06-20T08:24:22.210Z","dependency_job_id":"4b965840-4c68-42b7-9620-d9cd9e2d037d","html_url":"https://github.com/yeqown/snowflake","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Fsnowflake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Fsnowflake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Fsnowflake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Fsnowflake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeqown","download_url":"https://codeload.github.com/yeqown/snowflake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239665587,"owners_count":19676967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cli","cmake","library","lua","shared-library","static-library"],"created_at":"2024-11-07T18:37:06.133Z","updated_at":"2025-12-08T06:30:17.348Z","avatar_url":"https://github.com/yeqown.png","language":"C","readme":"# snowflake\n\nSnowflake is a network service for generating unique ID numbers at high scale with some simple guarantees.\n\n\n\u003cimg src=\"assets/format.png\" width=\"100%\"/\u003e\n\n### Goal\n\n- [x] developing a `c` library package.\n- [x] quickly use as a CLI application.\n- [x] extension to `lua`.\n- [ ] extension to `go`.\n\n### Installation\n\nThere are three ways to use `snowflake`:\n\n- [Library](#library)\n- [CLI application](#cli-application)\n- [Lua extension](#lua-extension)\n\n#### Library\n\nIn this way, you can use `snowflake` as a static library in your project.\n\n```bash\nmkdir build \u0026\u0026 cd build\ncmake ..\n\nmake snowflake_lib\n```\n\nThen you can copy the `build/libsnowflake.a` to your project or install it to your system manually.\n\n#### CLI application\n\nIn this way, you can use `snowflake` as a CLI application.\n\n```bash\nmkdir build \u0026\u0026 cd build\ncmake ..\n\nmake snowflake_cli\n```\n\nThen you can copy the `build/cmd/snowflake/snowflake` to your system path.\n\n### Lua extension\n\nIn this way, you can use `snowflake` as a lua extension.\n\n```bash\nmkdir build \u0026\u0026 cd build\ncmake ..\n\nmake snowflake_lua\n```\n\nThen you can copy the `build/contrib/lua/snowflake.so` to your lua `package.cpath`.\n\n### Generation process\n\nEach time you generate an ID, it works, like this.\n\n* A `timestamp` with millisecond precision is stored using 41 bits of the ID.\n* Then the `machineID` is added in subsequent bits.\n* Then the `counter` is added, starting at 0 and incrementing for each ID generated in the same millisecond. If you generate enough IDs in the same millisecond that the sequence would roll over or overfill then the generate function will pause until the next millisecond.\n\n\n### References\n\n* [twitter-snowflake](https://github.com/twitter-archive/snowflake)\n* thanks to [bwmarrin/snowflake](https://github.com/bwmarrin/snowflake)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeqown%2Fsnowflake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeqown%2Fsnowflake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeqown%2Fsnowflake/lists"}