依赖 validator插件 :
go install github.com/cloudwego/thrift-gen-validator@latest
微服务目前均不校验字段,此项任务交给api业务
kitex --thrift-plugin validator -module github.com/ClubWeGo/videomicro -service videomicro ./idl/video.thrift
without validator : kitex -module github.com/ClubWeGo/videomicro -service videomicro ./idl/video.thrift
go get github.com/cloudwego/kitex@latest && go mod tidy
- cmd/generateSchema :生成sql schema
- cmd/gormGen :自动生成query代码
./dal/model/user.go
cd cmd/migrateSchema/ && go run migrate.go
cd cmd/gormGen && go run gen.go
包装dal中的query,向handler暴露方法
- 编译 : sh ./build.sh
- 运行服务 : sh ./output/bootstrap.sh
- 运行client : cd /cmd/client && go run userclient.go
配置信息:
mysql8
- 库名 simpletk
- user tk
- password 123456
- dsn := "tk:123456@tcp(127.0.0.1:3306)/simpletk?charset=utf8&parseTime=True&loc=Local"
etcd
- 0.0.0.0:2379
docker部署
docker build -t imagename:version .
docker run -t -i --rm -p 8888:8888 --name testserver imagename:version /bin/bash