{"id":13714893,"url":"https://github.com/flike/idgo","last_synced_at":"2025-04-05T21:09:44.849Z","repository":{"id":44765510,"uuid":"48536194","full_name":"flike/idgo","owner":"flike","description":"id generator  based on MySQL","archived":false,"fork":false,"pushed_at":"2024-06-01T09:17:47.000Z","size":129,"stargazers_count":288,"open_issues_count":0,"forks_count":60,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-29T20:05:39.254Z","etag":null,"topics":["id-generation","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flike.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-24T09:32:01.000Z","updated_at":"2024-08-11T13:06:21.000Z","dependencies_parsed_at":"2024-06-19T03:14:22.700Z","dependency_job_id":"72c6286b-f672-4bcf-b655-04f062281099","html_url":"https://github.com/flike/idgo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flike%2Fidgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flike%2Fidgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flike%2Fidgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flike%2Fidgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flike","download_url":"https://codeload.github.com/flike/idgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399879,"owners_count":20932880,"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":["id-generation","redis"],"created_at":"2024-08-03T00:00:51.577Z","updated_at":"2025-04-05T21:09:44.832Z","avatar_url":"https://github.com/flike.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"## 1. Overview [中文主页](Readme_zh.md)\n[![Build Status](https://travis-ci.org/flike/idgo.svg?branch=master)](https://travis-ci.org/flike/idgo)\n\nIdgo is a sequential id generator which can generate batch ids through MySQL transcation way. Its features as follows:\n\n- The id generated by idgo is by order.\n-  generate batch ids through MySQL transcation way, dose not increase the load of MySQL.\n-  When idgo process crashed, admin can restart idgo, does not worry about generating repetitive ids.\n-  Idgo talks with clients using redis protocol, developer can connect idgo using redis sdk.\n\nSomeone knows the resolution of generating id with MySQL:\n\n```\nREPLACE INTO Tickets64 (stub) VALUES ('a');\nSELECT LAST_INSERT_ID();\n\n```\n\nThe disadvantage of this resolution is that generates one id need query MySQL once. When generating id too quickly, leading MySQL overload. This is why I build this project to generating ids.\n\n## 2. The architecture of idgo\n\nIdgo talks with clients using redis protocol, developer can connect to idgo using redis sdk. Every Key will mapped to a table storing in MySQL, and the table only has one row data to record the id.\n\n![idgo_arch](http://ww2.sinaimg.cn/large/6e5705a5gw1f2nz3bot3tj20qo0k0mxe.jpg)\n\nIdgo only supports four commands of redis as follows:\n\n- `SET key value`, set the initial value of id generator in idgo.\n- `GET key`, get the value of key.\n- `EXISTS key`, check the key if exist.\n- `DEL key`, delete the key in idgo.\n- `SELECT index`, just a mock select command, prevent the select command error.\n\n## 3. Install and use idgo\n\nInstall idgo following these steps:\n\n```\n\t1. Install Go environment, the version of Go   \nis greater than 1.3.\n\t2. Install godep. `go get github.com/tools/godep`. \n\t3. git clone https://github.com/flike/idgo src/github.com/flike/idgo\n\t4. cd src/github.com/flike/idgo\n\t5. source ./dev.sh\n\t6. make\n\t7. set the config file.\n \t8. run idgo. `./bin/idgo -config=etc/idgo.toml`\n\n```\nSet the config file(etc/idgo.toml):\n\n```\n#the address of idgo\naddr=\"127.0.0.1:6389\"\n#log_path: /Users/flike/src \nlog_level=\"debug\"\n\n[storage_db]\nmysql_host=\"127.0.0.1\"\nmysql_port=3306\ndb_name=\"idgo_test\"\nuser=\"root\"\npassword=\"\"\nmax_idle_conns=64\n\n```\n\nExamples:\n\n```\n\n#start idgo\n➜  idgo git:(master) ✗ ./bin/idgo -config=etc/idgo.toml\n2016/04/07 11:51:20 - INFO - server.go:[62] - [server] \"NewServer\" \"Server running\" \"netProto=tcp|address=127.0.0.1:6389\" req_id=0\n2016/04/07 11:51:20 - INFO - main.go:[80] - [main] \"main\" \"Idgo start!\" \"\" req_id=0\n\n#start a redis client to connecting idgo, and set/get the key.\n➜  ~  redis-cli -p 6389\nredis 127.0.0.1:6389\u003e get abc\n(integer) 0\nredis 127.0.0.1:6389\u003e set abc 100\nOK\nredis 127.0.0.1:6389\u003e get abc\n(integer) 101\nredis 127.0.0.1:6389\u003e get abc\n(integer) 102\nredis 127.0.0.1:6389\u003e get abc\n(integer) 103\nredis 127.0.0.1:6389\u003e get abc\n(integer) 104\n\n```\n\n## 4. HA\n\nWhen the idgo crashed, you can restart idgo and reset the key by increasing a fixed offset.\n\n## 5. License\n\nMIT \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflike%2Fidgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflike%2Fidgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflike%2Fidgo/lists"}