{"id":18457384,"url":"https://github.com/kayac/go-katsubushi","last_synced_at":"2025-04-07T12:10:16.978Z","repository":{"id":34190020,"uuid":"38043189","full_name":"kayac/go-katsubushi","owner":"kayac","description":"ID generator server","archived":false,"fork":false,"pushed_at":"2024-03-14T04:53:26.000Z","size":406,"stargazers_count":184,"open_issues_count":1,"forks_count":20,"subscribers_count":168,"default_branch":"v2","last_synced_at":"2025-04-06T00:25:01.006Z","etag":null,"topics":["go","golang","id-generation","katsubushi","kayac","memcached","snowflake"],"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/kayac.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":"2015-06-25T10:28:34.000Z","updated_at":"2025-03-16T02:18:34.000Z","dependencies_parsed_at":"2024-03-14T05:46:36.996Z","dependency_job_id":null,"html_url":"https://github.com/kayac/go-katsubushi","commit_stats":{"total_commits":174,"total_committers":16,"mean_commits":10.875,"dds":0.2931034482758621,"last_synced_commit":"357220b96501091aa815478f4507054692523150"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayac%2Fgo-katsubushi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayac%2Fgo-katsubushi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayac%2Fgo-katsubushi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayac%2Fgo-katsubushi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kayac","download_url":"https://codeload.github.com/kayac/go-katsubushi/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648977,"owners_count":20972945,"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":["go","golang","id-generation","katsubushi","kayac","memcached","snowflake"],"created_at":"2024-11-06T08:14:15.162Z","updated_at":"2025-04-07T12:10:16.957Z","avatar_url":"https://github.com/kayac.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# katsubushi\n\nkatsubushi(鰹節) is stand alone application to generate unique ID.\n\n## Example\n\n```\n$ telnet localhost 11212\nTrying ::1...\nConnected to localhost.\nEscape character is '^]'.\nGET new\nVALUE new 0 20\n8070450532247928832\nEND\n```\n\n## Installation\n\nDownload from [releases](https://github.com/kayac/go-katsubushi/releases) or build from source code.\n\n```\n$ go get github.com/kayac/go-katsubushi/v2\n$ cd $GOPATH/github.com/kayac/go-katsubushi\nmake\n```\n\n## Docker image\n\n- [katsubushi/katsubushi](https://hub.docker.com/r/katsubushi/katsubushi/)\n- [ghcr.io/kayac/go-katsubushi](https://github.com/kayac/go-katsubushi/pkgs/container/go-katsubushi)\n\n\n```\n$ docker pull katsubushi/katsubushi\n$ docker run -p 11212:11212 katsubushi/katsubushi -worker-id 1\n$ docker run -p 11212:11212 katsubushi/katsubushi -redis redis://your.redis.host:6379/0\n```\n\n## Usage\n\n```\n$ cd $GOPATH/github.com/kayac/go-katsubushi/cmd/katsubushi\n./katsubushi -worker-id=1 -port=7238\n./katsubushi -worker-id=1 -sock=/path/to/unix-domain.sock\n```\n\n## Protocol\n\nkatsubushi use protocol compatible with memcached.\n\nSome commands are available with text and binary protocol.\n\nBut the others are available only with text protocol.\n\n### API\n\n#### GET, GETS\n\nBinary protocol is also available only for single key GET.\n\n```\nGET id1 id2\nVALUE id1 0 18\n283890203179880448\nVALUE id2 0 18\n283890203179880449\nEND\n```\n\nVALUE(s) are unique IDs.\n\n#### STATS\n\nReturns a stats of katsubushi.\n\nBinary protocol is also available.\n\n```\nSTAT pid 8018\nSTAT uptime 17\nSTAT time 1487754986\nSTAT version 1.1.2\nSTAT curr_connections 1\nSTAT total_connections 2\nSTAT cmd_get 2\nSTAT get_hits 3\nSTAT get_misses 0\n```\n\n#### VERSION\n\nReturns a version of katsubushi.\n\nBinary protocol is available, too.\n\n```\nVERSION 1.1.2\n```\n\n#### QUIT\n\nDisconnect an established connection.\n\n## Protocol (HTTP)\n\nkatsubushi also runs an HTTP server specified with `-http-port`.\n\n### GET /id\n\nGet a single ID.\n\nWhen `Accept` HTTP header is 'application/json', katsubushi will return an ID as JSON format as below.\n\n```json\n{\"id\":\"1025441401866821632\"}\n```\n\nOtherwise, katsubushi will return ID as text format.\n\n```\n1025441401866821632\n```\n\n### GET /ids?n=(number_of_ids)\n\nGet multiple IDs.\n\nWhen `Accept` HTTP header is 'application/json', katsubushi will return an IDs as JSON format as below.\n\n```json\n{\"ids\":[\"1025442579472195584\",\"1025442579472195585\",\"1025442579472195586\"]}\n```\n\nOtherwise, katsubushi will return ID as text format delimiterd with \"\\n\".\n\n```\n1025442579472195584\n1025442579472195585\n1025442579472195586\n```\n\n### GET /stats\n\nReturns a stats of katsubushi.\n\nThis API returns a JSON always.\n\n```json\n{\n  \"pid\": 1859630,\n  \"uptime\": 50,\n  \"time\": 1664761614,\n  \"version\": \"1.8.0\",\n  \"curr_connections\": 1,\n  \"total_connections\": 5,\n  \"cmd_get\": 15,\n  \"get_hits\": 25,\n  \"get_misses\": 0\n}\n```\n\n## Protocol (gRPC)\n\nkatsubushi also runs an gRPC server specified with `-grpc-port`.\n\nSee [grpc/README.md](grpc/README.md).\n\n## Algorithm\n\nkatsubushi use algorithm like snowflake to generate ID.\n\n## Commandline Options\n\n`-worker-id` or `-redis` is required.\n\n### -worker-id\n\nID of the worker, must be unique in your service.\n\n### -redis\n\nURL of Redis server. e.g. `redis://example.com:6379/0`\n\n`redis://{host}:{port}/{db}?ns={namespace}`\n\nIf you are using Redis Cluster, you will need to specify the URL as `rediscluster://{host}:{port}?ns={namespace}`.\n\nThis option is specified, katsubushi will assign an unique worker ID via Redis.\n\nAll katsubushi process for your service must use a same Redis URL.\n\n### -min-worker-id -max-worker-id\n\nThese options work with `-redis`.\n\nIf we use multi katsubushi clusters, worker-id range for each clusters must not be overlapped. katsubushi can specify the worker-id range by these options.\n\n### -port\n\nOptional.\nPort number used for connection.\nDefault value is `11212`.\n\n### -sock\n\nOptional.\nPath of unix doamin socket.\n\n### -idle-timeout\n\nOptional.\nConnection idle timeout in seconds.\n`0` means infinite.\nDefault value is `600`.\n\n### -log-level\n\nOptional.\nDefault value is `info`.\n\n### -enable-pprof\n\nOptional.\nBoolean flag.\nEnable profiling API by `net/http/pprof`.\nEndpoint is `/debug/pprof`.\n\n### -enable-stats\n\nOptional.\nBoolean flag.\nEnable stats API by `github.com/fukata/golang-stats-api-handler`.\nEndpoint is `/debug/stats`.\n\n### -debug-port\n\nOptional.\nPort number for listen http used for `pprof` and `stats` API.\nDefalut value is `8080`.\n\n### -http-port\n\nOptional.\nPort number of HTTP server.\nDefault value is `0` (disabled).\n\n### -grpc-port\n\nOptional.\nPort number of gRPC server.\nDefault value is `0` (disabled).\n\n\n## Licence\n\n[MIT](https://github.com/kayac/go-katsubushi/blob/master/LICENSE)\n\n## Author\n\n[handlename](https://github.com/handlename)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayac%2Fgo-katsubushi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkayac%2Fgo-katsubushi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayac%2Fgo-katsubushi/lists"}