modulepackage
0.0.0-20241214151252-8d73729f86f6
Repository: https://github.com/colinrs/goleaf.git
Documentation: pkg.go.dev
# README
Overview
Goleaf is a distributed ID generation system that supports:
- Snowflake algorithm
- Segment mode for generating unique IDs
Architecture Components
- goleaf: Core service for generating distributed IDs
- SDK: Client library for obtaining IDs
- MySQL: Database for storing business information
- etcd: Used for obtaining node ID (for Snowflake algorithm)
- Redis: Caching service
Prerequisites for Deployment
- etcd deployment
- MySQL deployment
- Redis deployment
Database Setup
A leaf_alloc table is created in MySQL with columns:
- id: Auto-increment primary key
- biz_tag: Business tag (up to 128 characters)
- max_id: Maximum ID (default 1)
- step: Increment step
- description: Optional description
- Timestamps for creation, update, and deletion
create table leaf.leaf_alloc
(
id int auto_increment
primary key,
biz_tag varchar(128) default '' not null,
max_id bigint default 1 not null,
step int not null,
description varchar(256) default '' not null ,
created_at timestamp default current_timestamp not null,
updated_at timestamp default current_timestamp not null,
deleted_at timestamp default null
);
create index leaf_alloc_biz_tag_index
on leaf.leaf_alloc (biz_tag);
Compilation and Startup
- Build command: make build (generates binary in ./bin)
- Start service: ./bin/goleaf -f etc/goleaf-api.yaml
Development Tools
- make swagger: Generate Swagger documentation
- make all: Format API docs, generate Go code and Swagger docs
- make build: Compile and generate binary
# Packages
No description provided by the author