{"id":37186698,"url":"https://github.com/oscarpfernandez/idgen","last_synced_at":"2026-01-14T21:39:37.331Z","repository":{"id":57528750,"uuid":"97418218","full_name":"oscarpfernandez/idgen","owner":"oscarpfernandez","description":"Sparsely Sequential 64bit ID Generator","archived":false,"fork":false,"pushed_at":"2017-07-17T02:17:34.000Z","size":1163,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T14:10:32.971Z","etag":null,"topics":["golang-library","idgenerator","utility-library"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oscarpfernandez.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-07-16T23:50:53.000Z","updated_at":"2017-07-17T13:09:58.000Z","dependencies_parsed_at":"2022-09-10T17:10:24.318Z","dependency_job_id":null,"html_url":"https://github.com/oscarpfernandez/idgen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oscarpfernandez/idgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscarpfernandez%2Fidgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscarpfernandez%2Fidgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscarpfernandez%2Fidgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscarpfernandez%2Fidgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oscarpfernandez","download_url":"https://codeload.github.com/oscarpfernandez/idgen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscarpfernandez%2Fidgen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["golang-library","idgenerator","utility-library"],"created_at":"2026-01-14T21:39:36.693Z","updated_at":"2026-01-14T21:39:37.319Z","avatar_url":"https://github.com/oscarpfernandez.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SSID - Sparsely Sequential ID\n\nThis algorithm generates sparsely sequencial 64-bit ID's, that are based in three main components: timestamp, worker/process number and a sequence number.\nThese are called sparsely sorted (or in mathematical terms [`k-sorted`](http://ci.nii.ac.jp/naid/110002673489/)). For example, keeping the `k` around the 10ms mark, between each ID generation batches, say A1 and A2, we guarantee that `ID(A1) \u003c ID(A2)`, and also that both batches will be within 10ms in the ID space as well.\n\nThis project gets some of the foundational concepts out of the [Snowflake Project](https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake.html) the ID generator.\n\nThis ID generator is suitable to be used in a distributed environemnt, generating a 64-bit ID based in three components:\n\n| Field | Bit lenght | Max value |Description |\n| --- | --- | --- | --- |\n| Timestamp | 40 | ~34.8 years | Machine's timestamp in miliseconds since a defined start date |\n| GeneratorID | 8 | 256 | ID that identifies the instance that is generating the SSID |\n| SequenceID | 15 | 32767 | The number of elements that can be generated with a single timestamp |\n\nThe only configurable ID is the `GeneratorID` that can represent a given machine, process, etc.\n\nThe base API is defined under the `ssid` package.\n\nTo use the API, two modalities are provided: a command line interface and a simple REST server.\n\n\n## Build the image:\n\nThe simplest way to compile the project is by using [Docker](https://www.docker.com).\n\n```\ndocker build -t ssid .\n```\n\n## (Option #1) Run the command line interface:\n\n  Generate 1000 SSIDs\n  ```\n  docker run -ti ssid idgen generate -c 1000\n  ```\n\n  Example:\n  ```bash\n  INFO[0000] Configuration: {GeneratorID:0 StartTime:2016-07-04 00:00:00 +0000 UTC}\n  INFO[0000] SSID: 268066528266551297\n  INFO[0000] SSID: 268066528266551298\n  INFO[0000] SSID: 268066528266551299\n  INFO[0000] SSID: 268066528266551300\n  INFO[0000] SSID: 268066528266551301\n  INFO[0000] Total Generation Time: 12.685µs\n  ```\n\n  To ge the full options available by the command line run\n  ```\n  docker run -ti ssid  idgen generate --help\n  ```\n##  (Option #2) Run the REST server\n\n  ```\n  docker run -p 8080:8080  -t ssid\n  ```\n  This starts a REST webserver making it available in the por 8080.\n\n  To reach the server hit the following endpoints:\n\n###  1. Generate a single SSID:\n  Running on  curl or browser:\n  ```\n  http://localhost:8080/ssid\n  ```\n  Example response:\n  ```json\n  {\n    \"config\": {\n      \"GeneratorID\": 0,\n      \"StartTime\": \"2016-07-04T00:00:00Z\"\n    },\n    \"ssids\": [\n      267965642873765889\n    ]\n  }\n  ```\n\n###  2. Generate a set of SSIDs:\n  ```\n  http://localhost:8080/ssid/\u003c#SSID\u003e/\u003cGeneratorID\u003e\n  ```\n  * `\u003c#SSID\u003e - number of SSIDs to generate`\n\n  * `\u003cGeneratorID\u003e - generator ID`\n\n  Running on curl or browser:\n  ```\n  http://localhost:8080/ssid/1000/7\n  ```\n  Example response:\n  ```json\n  \"config\": {\n    \"GeneratorID\": 7,\n    \"StartTime\": \"2016-07-04T00:00:00Z\"\n  },\n  \"ssids\": [\n    267968567352262657,\n    267968567352262658,\n    267968567352262659,\n    267968567352262660,\n    267968567352262661,\n    267968567352262662,\n    267968567352262663,\n    267968567352262664,\n    267968567352262665,\n    267968567352262666,\n    267968567352262667,\n    267968567352262668,\n    267968567352262669,\n    267968567352262670,\n    267968567352262671,\n    267968567352262672,\n    267968567352262673,\n    267968567352262674,\n    267968567352262675,\n    (...)\n  ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscarpfernandez%2Fidgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foscarpfernandez%2Fidgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscarpfernandez%2Fidgen/lists"}