{"id":37134565,"url":"https://github.com/younglifestyle/goleaf","last_synced_at":"2026-01-14T15:42:11.218Z","repository":{"id":52058360,"uuid":"480763066","full_name":"younglifestyle/goLeaf","owner":"younglifestyle","description":"golang leaf，REF. Meituan-Dianping Leaf，ID发号器","archived":false,"fork":false,"pushed_at":"2025-09-20T12:58:47.000Z","size":416,"stargazers_count":77,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-20T14:51:11.050Z","etag":null,"topics":["go-kratos","golang","kratos","leaf"],"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/younglifestyle.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":"2022-04-12T10:35:46.000Z","updated_at":"2025-09-20T12:58:51.000Z","dependencies_parsed_at":"2024-01-14T04:43:48.584Z","dependency_job_id":"f99316c6-c756-4c97-bc1d-2335a179841f","html_url":"https://github.com/younglifestyle/goLeaf","commit_stats":null,"previous_names":["younglifestyle/seg-server"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/younglifestyle/goLeaf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younglifestyle%2FgoLeaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younglifestyle%2FgoLeaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younglifestyle%2FgoLeaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younglifestyle%2FgoLeaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/younglifestyle","download_url":"https://codeload.github.com/younglifestyle/goLeaf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younglifestyle%2FgoLeaf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","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":["go-kratos","golang","kratos","leaf"],"created_at":"2026-01-14T15:42:10.561Z","updated_at":"2026-01-14T15:42:11.210Z","avatar_url":"https://github.com/younglifestyle.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leaf\n\n\u003e There are no two identical leaves in the world.\n\u003e\n\u003e ```\n\u003e — Leibnitz\n\u003e ```\n\u003e\n\n[中文文档](./README_zh.md) | [English Document](./README.md)\n\n## Introduce\n\nA number segment pattern and Snowflake ID generator implemented in Go, based on the Kratos framework, suitable for this microservices framework and service discovery service.\n\nThe gRPC access performance is on par with Leaf.\n\n\u003e Interface compatible with Leaf, can be directly replaced\n\u003e\n\u003e Add the functionality to automatically reset the serial number every day (add the `auto_clean` field, intended for single-node use, with Nginx backup).\n\u003e\n\u003e Add an api to support remote addition of number segment tags.\n\u003e\n\u003e Add an api for bulk retrieval of number segments.\n\u003e\n\u003e Introduce a new UI interface that supports adding, viewing number segments, caching, and parsing Snowflake IDs.\n\n## Quick Start\n\n### Segment Pattern\n\n- table\n\n```mysql\nCREATE DATABASE leaf;\n\nCREATE TABLE `leaf_alloc` (\n    `biz_tag` varchar(128)  NOT NULL DEFAULT '', -- your biz unique name\n    `max_id` bigint(20) NOT NULL DEFAULT '1',\n    `step` int(11) NOT NULL,\n    `description` varchar(256)  DEFAULT NULL,\n    `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n    `auto_clean` tinyint(1) default 0 null,\n    PRIMARY KEY (`biz_tag`)\n) ENGINE=InnoDB;\n\ninsert into leaf_alloc(biz_tag, max_id, step, description) values('leaf-segment-test', 1, 2000, 'Test leaf Segment Mode Get Id');\n```\n\n- config\n\n```yaml\ndata:\n  database:\n    segment_enable: true\n    table_name: \"leaf_alloc\"\n    driver: mysql\n    source: root:123@tcp(127.0.0.1:3306)/leaf?charset=utf8\u0026parseTime=True\u0026loc=Local\n    open_conn: 50\n    idle: 10\n    idle_timeout: 14400s\n```\n\n- run\n\n```\nmake build\nbin/goLeaf -conf configs/config.yaml\n```\n\n- api\n\n```\ncurl http://localhost:8000/api/segment/get/leaf-segment-test\n\n// cache data\nhttp://localhost:8000/monitor/cache\n// db segment data\nhttp://localhost:8000/monitor/db\n```\n\n### Snowflake Pattern\n\n- config\n\n```yaml\ndata:\n  etcd:\n    snowflake_enable: true\n    # Enabling the functionality to synchronize and validate time with other Leaf nodes.\n    discovery_enable: false\n    endpoints: [\"127.0.0.1:2379\"]\n    dial_timeout: 2s\n    # When `discovery_enable` is enabled, the deviation in time among service nodes.\n    time_deviation: 50\n```\n\n- api\n\n```\ncurl http://localhost:8000/api/snowflake/get\n\n// decode ID\nhttp://localhost:8000/decodeSnowflakeId\n```\n\n### UI\n\naddr：http:port/web\n\n\u003e 例如：http://127.0.0.1:8001/web\n\n![DB号段](doc/image-20221101201529905.jpg)\n\n---\n\n![cache中的号段](doc/image-20221101201630411.jpg)\n\n---\n\n![雪花ID解析](doc/image-20221101201705230.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounglifestyle%2Fgoleaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyounglifestyle%2Fgoleaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounglifestyle%2Fgoleaf/lists"}