{"id":38009836,"url":"https://github.com/alsey/uid-gen","last_synced_at":"2026-01-16T19:19:36.303Z","repository":{"id":57545223,"uuid":"111488988","full_name":"alsey/uid-gen","owner":"alsey","description":"Generate global unique id in sequence.","archived":false,"fork":false,"pushed_at":"2017-11-21T02:37:23.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T08:01:10.228Z","etag":null,"topics":["gid","golang","mysql","redis","sequence","sequence-id","service","uid"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/alsey.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-11-21T02:35:35.000Z","updated_at":"2023-04-30T15:09:17.000Z","dependencies_parsed_at":"2022-09-16T23:21:54.253Z","dependency_job_id":null,"html_url":"https://github.com/alsey/uid-gen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alsey/uid-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsey%2Fuid-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsey%2Fuid-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsey%2Fuid-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsey%2Fuid-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alsey","download_url":"https://codeload.github.com/alsey/uid-gen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsey%2Fuid-gen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["gid","golang","mysql","redis","sequence","sequence-id","service","uid"],"created_at":"2026-01-16T19:19:36.190Z","updated_at":"2026-01-16T19:19:36.281Z","avatar_url":"https://github.com/alsey.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Global Sequence Unique ID Generator\n\nGenerate global unique id in sequence.\n\nThe concept is 2-layer generating system, first layer generates unique id by redis service, and second layer persistences id by mysql backend.\n\nWhen the server start, it will synchronizes MySQL and Redis first, so it can be used in distribute system envionment safely.\n\n## Installation\n\n```bash\n$ go get github.com/alsey/uid-gen\n```\n\n## Connfiguration\n\n  Use envionment variables to config this service.\n\n- PORT0 : port, default is 3000\n- MYSQL_DSN : mysql connection string, default is root:password@tcp(127.0.0.1:3306)/counter?charset=utf8\n- REDIS_HOST : redis service address, default is 127.0.0.1\n- REDIS_PORT : redis service port, default is 6379\n\n## How to Use\n\n1. Use a key, generate unique id in sequence\n\nEvery time access the URL, the server will return a unique id. Default the id starts with 1, then 2, 3, 4... in sequence.\n\n```\nhttp://\u003chost\u003e:\u003cport\u003e/\u003csome_key\u003e\n```\n\n2. Set the start number\n\nYou can set the start number not the default 1.\n\n```\nhttp://\u003chost\u003e:\u003cport\u003e/\u003csome_key\u003e?start=99\n```\n\nThe key starts with 99, then 100, 101, 102... in sequence.\n\n3. Set the step\n\nYou can set the step not the default 1.\n\n```\nhttp://\u003chost\u003e:\u003cport\u003e/\u003csome_key\u003e?step=2\n```\n\nThe key step is 2, first time return 1, then 3, 5, 7, 9... in sequence.\n\nThe step also can be negative number. \n\n```\nhttp://\u003chost\u003e:\u003cport\u003e/\u003csome_key\u003e?start=100\u0026step=-2\n```\n\nThe service return 100, then 98, 96, 94... in sequence.\n\n4. I wrote a Dockerfile for you, you can make a Docker image, and put it in Kubernetes or Mesos.\n\n```bash\n$ docker build -t 'mongo-image-server' .\n```\n\n5. The server includes a health check endpoint for microservice scenario.\n\n```\nhttp://\u003chost\u003e:\u003cport\u003e/health\nhttp://\u003chost\u003e:\u003cport\u003e/env\n```\n\n## License\n\n  [MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsey%2Fuid-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falsey%2Fuid-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsey%2Fuid-gen/lists"}