44
55A REST API server for exploring and managing TiKV key-value data with multi-cluster support.
66
7- ## Project Structure
8-
9- ```
10- tikv-ui/
11- ├── cmd/
12- │ └── tikv-ui/
13- │ └── main.go # Application entry point
14- ├── pkg/
15- │ ├── handlers/ # HTTP request handlers
16- │ │ ├── health.go # Health check endpoint
17- │ │ ├── cluster.go # Cluster management
18- │ │ ├── get.go # GET operation
19- │ │ ├── put.go # PUT operation
20- │ │ ├── delete.go # DELETE operation
21- │ │ └── scan.go # SCAN operation
22- │ ├── server/ # Server setup and middleware
23- │ │ ├── server.go # Server struct with multi-cluster support
24- │ │ └── middleware.go # HTTP middleware (logging, etc.)
25- │ ├── types/ # Type definitions
26- │ │ ├── requests.go # API request types
27- │ │ └── responses.go # API response types
28- │ └── utils/ # Utility functions
29- │ ├── http.go # HTTP helpers (JSON responses, errors)
30- │ ├── msgpack.go # Msgpack/JSON parsing
31- │ └── string.go # String manipulation utilities
32- ├── go.mod
33- ├── go.sum
34- └── README.md
35- ```
36-
377## Building
388
399``` bash
@@ -54,13 +24,15 @@ The server will start on port 8081 and connect to the default cluster.
5424## API Endpoints
5525
5626### Health Check
27+
5728```
5829GET /health
5930```
6031
6132### Cluster Management
6233
6334#### Connect to New Cluster
35+
6436```
6537POST /api/clusters/connect
6638Body: {
@@ -70,6 +42,7 @@ Body: {
7042```
7143
7244#### List All Clusters
45+
7346```
7447GET /api/clusters
7548Response: {
@@ -85,6 +58,7 @@ Response: {
8558```
8659
8760#### Switch Active Cluster
61+
8862```
8963POST /api/clusters/switch
9064Body: {"name": "production"}
@@ -95,6 +69,7 @@ Body: {"name": "production"}
9569All operations use the currently active cluster.
9670
9771#### Get Value
72+
9873```
9974POST /api/raw/get
10075Body: {"key": "mykey"}
@@ -107,18 +82,21 @@ Response: {
10782```
10883
10984#### Put Value
85+
11086```
11187POST /api/raw/put
11288Body: {"key": "mykey", "value": "myvalue"}
11389```
11490
11591#### Delete Key
92+
11693```
11794POST /api/raw/delete
11895Body: {"key": "mykey"}
11996```
12097
12198#### Scan Range
99+
122100```
123101POST /api/raw/scan
124102Body: {"start_key": "a", "end_key": "z", "limit": 100}
@@ -136,18 +114,21 @@ Response: {
136114## Features
137115
138116### Multi-Cluster Support
117+
139118- Connect to multiple TiKV clusters dynamically via API
140119- Switch between clusters without restarting the server
141120- Each cluster maintains its own connection pool
142121- Thread-safe cluster management
143122
144123### Smart Value Parsing
124+
145125- Automatically detects and parses msgpack-encoded values
146126- Falls back to JSON parsing if msgpack fails
147127- Returns both parsed (structured) and raw (string) values
148128- Handles plain text values correctly
149129
150130### Graceful Shutdown
131+
151132- Properly closes all cluster connections on shutdown
152133- Handles SIGINT and SIGTERM signals
153134
@@ -162,6 +143,7 @@ The project follows a clean architecture pattern:
162143- ** pkg/utils/** : Reusable utility functions
163144
164145This structure provides:
146+
165147- Clear separation of concerns
166148- Easy testing (each handler can be tested independently)
167149- Maintainability (changes are localized to specific packages)
0 commit comments