{"id":17964807,"url":"https://github.com/tkyshm/esnowflake","last_synced_at":"2025-07-14T22:38:18.067Z","repository":{"id":57497175,"uuid":"108713098","full_name":"tkyshm/esnowflake","owner":"tkyshm","description":"Uniq id generator based on Twitter's snowflake in Erlang","archived":false,"fork":false,"pushed_at":"2019-08-23T06:43:43.000Z","size":3639,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T18:52:23.552Z","etag":null,"topics":["erlang","otp","snowflake","uuid-generator"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/tkyshm.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}},"created_at":"2017-10-29T07:11:03.000Z","updated_at":"2022-05-26T07:53:02.000Z","dependencies_parsed_at":"2022-09-03T23:20:46.464Z","dependency_job_id":null,"html_url":"https://github.com/tkyshm/esnowflake","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/tkyshm/esnowflake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkyshm%2Fesnowflake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkyshm%2Fesnowflake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkyshm%2Fesnowflake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkyshm%2Fesnowflake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkyshm","download_url":"https://codeload.github.com/tkyshm/esnowflake/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkyshm%2Fesnowflake/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265362244,"owners_count":23753112,"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":["erlang","otp","snowflake","uuid-generator"],"created_at":"2024-10-29T12:08:48.678Z","updated_at":"2025-07-14T22:38:18.018Z","avatar_url":"https://github.com/tkyshm.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/tkyshm/esnowflake.svg?branch=master)](https://travis-ci.org/tkyshm/esnowflake)\n\nesnowflake\n=====\n\nesnowflake is Erlang/OTP application to generate uniq ID.  \nOriginal design: [Twitter IDs (snowflake)](https://github.com/twitter/snowflake).  \n[Documentation](https://hexdocs.pm/esnowflake/0.1.0/)\n\nUsage\n=====\n\n```erlang\n\u003e application:start(esnowflake).\nok\n\n\u003e Id = esnowflake:generate_id().\n896221795344384\n\n\u003e esnowflake:generate_ids(2).\n[896498611015681,896498611015680]\n\n\u003e esnowflake:to_unixtime(Id).\n1509193995927\n\n\u003e esnowflake:stats().\n[{version, undefined},\n {worker_num,10},\n {worker_ids,[0,1,2,3,4,5,6,7,8,9]}]\n\n1\u003e {Start, End} = {os:system_time(seconds)-3600*24, os:system_time(seconds)}.\n{1528603140,1528689540}\n2\u003e esnowflake:range_ids(Start,End, seconds).\n[82304072417280000,82666460287074303]\n\n```\n\nConfig\n=====\n\n## worker id\n\n### application environment variable\n\nThis must be specified as not to duplicate worker ids if you use multi nodes.\n\nparams            | default       | explain\n----------------- | ------------- | ---------------------------------------------------------\nworker_num        | 2             | number of generate id workers\nworker_min_max_id | [0, 1]        | worker ids\nredis             | -             | eredis config for assigning worker ids automatically\ntwepoch           | 1508980320000 | start unix time to number id (default: 2017-10-26 01:12:00 (UTC))\n\n\n- redis config\n\nparams          | default\n--------------- | ----------------------------------\nhost            | localhost\nport            | 6379\ndatabase        | 0\npassword        | (empty)\nreconnect_sleep | please check `eredis:start_link/1`\nconnect_timeout | please check `eredis:start_link/1`\n\n\n- app.conf\n\n```erlang\n[\n {esnowflake, [\n               {worker_min_max_id, [0, 1]}\n              ]}\n].\n```\n\n```erlang\n[\n {esnowflake, [\n               {redis, [{host, \"localhost\"}, {port, 26379}]},\n               {worker_num, 2}\n              ]}\n].\n```\n\nBench\n=====\n\n```\n----------------------------------------------------\n2017-10-29 16:03:27.671\nb_generate_id\t100000\t4564.13864 ns/op\n\n\n----------------------------------------------------\n2017-10-29 16:03:28.703\nb_generate_id\t232502 op/sec\n\n%%% esnowflake_SUITE ==\u003e bench.b_generate_id: OK\n\n----------------------------------------------------\n2017-10-29 16:03:29.700\nb_generate_ids_100\t10000\t96834.8342 ns/op\n\n\n----------------------------------------------------\n2017-10-29 16:03:30.702\nb_generate_ids_100\t686 op/sec\n\n%%% esnowflake_SUITE ==\u003e bench.b_generate_ids: OK\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkyshm%2Fesnowflake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkyshm%2Fesnowflake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkyshm%2Fesnowflake/lists"}