Skip to content

Commit 1601a96

Browse files
committed
feat: implement mini raftkv
0 parents  commit 1601a96

37 files changed

Lines changed: 4525 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v5
15+
16+
- name: Setup Go
17+
uses: actions/setup-go@v6
18+
with:
19+
go-version-file: go.mod
20+
cache: true
21+
22+
- name: Verify generated protobuf code
23+
run: |
24+
go install github.com/bufbuild/buf/cmd/buf@latest
25+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
26+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
27+
make proto
28+
git diff --exit-code
29+
30+
- name: Test
31+
run: go test ./...
32+
33+
- name: Build binaries
34+
run: make build

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bin/
2+
data/
3+
logs/
4+
/raftkv
5+
/raftkvctl
6+
*.db
7+
*.db.lock
8+
.DS_Store

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM golang:1.26-alpine AS build
2+
3+
WORKDIR /src
4+
COPY go.mod go.sum ./
5+
RUN go mod download
6+
COPY . .
7+
RUN go build -o /out/raftkv ./cmd/raftkv
8+
RUN go build -o /out/raftkvctl ./cmd/raftkvctl
9+
10+
FROM alpine:3.22
11+
12+
WORKDIR /app
13+
COPY --from=build /out/raftkv /usr/local/bin/raftkv
14+
COPY --from=build /out/raftkvctl /usr/local/bin/raftkvctl
15+
COPY configs ./configs
16+
17+
ENTRYPOINT ["raftkv"]

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.PHONY: proto test build run-n1 run-n2 run-n3 run-cluster demo bench clean docker-up docker-down
2+
3+
proto:
4+
$$(go env GOPATH)/bin/buf generate api --template buf.gen.yaml
5+
6+
test:
7+
go test ./...
8+
9+
build:
10+
go build -o bin/raftkv ./cmd/raftkv
11+
go build -o bin/raftkvctl ./cmd/raftkvctl
12+
13+
run-n1:
14+
go run ./cmd/raftkv -config configs/n1.yaml
15+
16+
run-n2:
17+
go run ./cmd/raftkv -config configs/n2.yaml
18+
19+
run-n3:
20+
go run ./cmd/raftkv -config configs/n3.yaml
21+
22+
run-cluster:
23+
scripts/run-local-cluster.sh
24+
25+
demo:
26+
scripts/demo-flow.sh
27+
28+
bench:
29+
scripts/bench.sh
30+
31+
docker-up:
32+
docker compose up --build
33+
34+
docker-down:
35+
docker compose down -v
36+
37+
clean:
38+
rm -rf bin data

0 commit comments

Comments
 (0)