Skip to content

Commit

Permalink
refactor: split codes and fix fuzzy show on maps (#159)
Browse files Browse the repository at this point in the history
- split server to different pkgs
- fix fuzzy data show as GeoJSON
- update lint
  • Loading branch information
ringsaturn authored Mar 17, 2024
1 parent 11556ce commit 7de975a
Show file tree
Hide file tree
Showing 32 changed files with 1,345 additions and 689 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,29 @@ on:
branches: [main]

jobs:
buf:
name: buf
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.22"
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1
with:
version: "latest"
- uses: bufbuild/buf-lint-action@v1
- uses: bufbuild/buf-breaking-action@v1
with:
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main"

golangci:
name: golangci-lint
needs: [buf]
strategy:
matrix:
go: ["1.22"]
Expand All @@ -31,8 +52,9 @@ jobs:
version: latest
args: --timeout=5m

build:
test:
runs-on: ubuntu-latest
needs: [golangci]
strategy:
matrix:
go: ["1.22"]
Expand All @@ -44,8 +66,7 @@ jobs:
with:
go-version: ${{ matrix.go }}

- run: go install github.com/mfridman/tparse@latest

- run: make install
- run: make build
- run: make test
- run: make bench
Expand Down
35 changes: 25 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
GOBASEPATH=$(shell go env var GOPATH | xargs)

help: ## Show this help.
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'


.PHONY:build
build:
build: ## Build tzf server
go build

.PHONY:test
test:
test: ## Run test
go test -json -race ./... -v -coverprofile=coverage.txt -covermode=atomic | tparse -all

.PHONY:bench
bench:
bench: ## Run benchmark
go test -bench=. -benchmem ./...

.PHONY:cover
cover:
cover: ## Generate coverage report
go tool cover -html=coverage.txt -o=coverage.html

mock:
mockgen -source=$(GOBASEPATH)/pkg/mod/github.com/tidwall/redcon@v1.6.2/redcon.go -destination="handler/mock_redcon_test.go" -package=handler_test
mock: ## Generate mock
mockgen -source=$(GOBASEPATH)/pkg/mod/github.com/tidwall/redcon@v1.6.2/redcon.go -destination="internal/redisserver/mock_redcon_test.go" -package=redisserver_test

install:
go install github.com/favadi/protoc-go-inject-tag@latest
install: ## Install tools
go install github.com/mfridman/tparse@latest
go install go.uber.org/mock/mockgen@latest
go install github.com/wolfogre/gtag/cmd/gtag@latest
go install github.com/google/wire/cmd/wire@latest
go install github.com/favadi/protoc-go-inject-tag@latest
go install github.com/ringsaturn/protoc-gen-go-hertz@latest

.PHONY:pb
pb:
pb: ## Generate protobuf
buf build
buf generate
protoc-go-inject-tag -input="tzf/v1/*.pb.go" -remove_tag_comment
go fmt ./...

fmt:
fmt: ## Format code
find proto/v1 -iname *.proto | xargs clang-format -i --style=Google
go fmt ./...
go fix ./...

gtag: ## Generate gtag
cd internal/config;gtag -types Config -tags flag .

gen: ## Generate code
make pb
make mock
make gtag
4 changes: 3 additions & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ plugins:
out: .
opt:
- paths=source_relative
# local plugins: protoc-gen-<plugin>
- plugin: go-hertz
out: .
opt:
- paths=source_relative
- plugin: go-grpc-mock
out: .
opt: paths=source_relative
4 changes: 2 additions & 2 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: b30c5775bfb3485d9da2e87b26590ac9
digest: shake256:9d0caaf056949a0e1c883b9849d8a2fa66e22f18a2a48f867d1a8c700aa22abee50ad3ef0d8171637457cadc43c584998bdf3adac55da0f9e4614c72686b057d
commit: ee48893a270147348e3edc6c1a03de0e
digest: shake256:a35b0576a2b55dad72747e786af05c03539c2b96be236c9de39fe10d551931ac252eb68445c0cef6bbd27fa20e8c26eee5b8a9fe9c2fde6f63a03e18f8cf980d
29 changes: 18 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ go 1.22.0

require (
github.com/cloudwego/hertz v0.8.1
github.com/favadi/protoc-go-inject-tag v1.4.0
github.com/google/go-cmp v0.6.0
github.com/google/wire v0.6.0
github.com/hertz-contrib/logger/zap v1.1.0
github.com/hertz-contrib/monitor-prometheus v0.1.2
github.com/hertz-contrib/swagger v0.1.0
Expand All @@ -16,10 +18,11 @@ require (
github.com/ringsaturn/tzf-rel-lite v0.0.2024-a
github.com/swaggo/files v1.0.1
github.com/tidwall/redcon v1.6.2
github.com/wolfogre/gtag v0.9.0
go.uber.org/mock v0.4.0
go.uber.org/zap v1.27.0
golang.org/x/sync v0.6.0
google.golang.org/genproto/googleapis/api v0.0.0-20240308144416-29370a3891b7
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
)
Expand All @@ -30,29 +33,32 @@ require (
github.com/andeya/goutil v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/go-tagexpr/v2 v2.9.11 // indirect
github.com/bytedance/gopkg v0.0.0-20240202110943-5e26950c5e57 // indirect
github.com/bytedance/sonic v1.11.2 // indirect
github.com/bytedance/gopkg v0.0.0-20240315062850-21fc7a1671a8 // indirect
github.com/bytedance/sonic v1.11.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/cloudwego/netpoll v0.6.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gochore/uniq v1.1.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/subcommands v1.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nyaruka/phonenumbers v1.3.2 // indirect
github.com/nyaruka/phonenumbers v1.3.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.50.0 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/swaggo/swag v1.16.1 // indirect
github.com/swaggo/swag v1.16.3 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/tidwall/geoindex v1.7.0 // indirect
github.com/tidwall/geojson v1.4.5 // indirect
Expand All @@ -66,10 +72,11 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 7de975a

Please sign in to comment.