From d696206dc7ddc08804cf7e244ea8a5f94b870369 Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Fri, 17 Jan 2025 17:09:32 +0800 Subject: [PATCH] init --- .idea/.gitignore | 8 + .idea/hertz101.iml | 9 + .idea/modules.xml | 8 + .idea/vcs.xml | 4 + Makefile | 6 + app/user/.gitignore | 35 ++ app/user/biz/dal/init.go | 11 + app/user/biz/dal/mysql/init.go | 25 + app/user/biz/dal/redis/init.go | 24 + app/user/biz/service/login.go | 20 + app/user/biz/service/login_test.go | 21 + app/user/biz/service/register.go | 20 + app/user/biz/service/register_test.go | 21 + app/user/build.sh | 7 + app/user/conf/conf.go | 110 +++++ app/user/conf/dev/conf.yaml | 23 + app/user/conf/online/conf.yaml | 23 + app/user/conf/test/conf.yaml | 23 + app/user/docker-compose.yaml | 15 + app/user/go.mod | 54 +++ app/user/go.sum | 50 ++ app/user/handler.go | 24 + app/user/kitex_info.yaml | 3 + app/user/main.go | 59 +++ app/user/readme.md | 26 ++ app/user/script/bootstrap.sh | 4 + go.work | 6 + go.work.sum | 45 ++ idl/user.proto | 28 ++ rpc_gen/go.mod | 51 +++ rpc_gen/go.sum | 257 +++++++++++ rpc_gen/kitex_gen/user/user.pb.fast.go | 315 +++++++++++++ rpc_gen/kitex_gen/user/user.pb.go | 371 +++++++++++++++ rpc_gen/kitex_gen/user/userservice/client.go | 55 +++ rpc_gen/kitex_gen/user/userservice/invoker.go | 24 + rpc_gen/kitex_gen/user/userservice/server.go | 24 + .../kitex_gen/user/userservice/userservice.go | 432 ++++++++++++++++++ rpc_gen/rpc/user/user_client.go | 50 ++ rpc_gen/rpc/user/user_default.go | 26 ++ rpc_gen/rpc/user/user_init.go | 40 ++ 40 files changed, 2357 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/hertz101.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Makefile create mode 100644 app/user/.gitignore create mode 100644 app/user/biz/dal/init.go create mode 100644 app/user/biz/dal/mysql/init.go create mode 100644 app/user/biz/dal/redis/init.go create mode 100644 app/user/biz/service/login.go create mode 100644 app/user/biz/service/login_test.go create mode 100644 app/user/biz/service/register.go create mode 100644 app/user/biz/service/register_test.go create mode 100644 app/user/build.sh create mode 100644 app/user/conf/conf.go create mode 100644 app/user/conf/dev/conf.yaml create mode 100644 app/user/conf/online/conf.yaml create mode 100644 app/user/conf/test/conf.yaml create mode 100644 app/user/docker-compose.yaml create mode 100644 app/user/go.mod create mode 100644 app/user/go.sum create mode 100644 app/user/handler.go create mode 100644 app/user/kitex_info.yaml create mode 100644 app/user/main.go create mode 100644 app/user/readme.md create mode 100644 app/user/script/bootstrap.sh create mode 100644 go.work create mode 100644 go.work.sum create mode 100644 idl/user.proto create mode 100644 rpc_gen/go.mod create mode 100644 rpc_gen/go.sum create mode 100644 rpc_gen/kitex_gen/user/user.pb.fast.go create mode 100644 rpc_gen/kitex_gen/user/user.pb.go create mode 100644 rpc_gen/kitex_gen/user/userservice/client.go create mode 100644 rpc_gen/kitex_gen/user/userservice/invoker.go create mode 100644 rpc_gen/kitex_gen/user/userservice/server.go create mode 100644 rpc_gen/kitex_gen/user/userservice/userservice.go create mode 100644 rpc_gen/rpc/user/user_client.go create mode 100644 rpc_gen/rpc/user/user_default.go create mode 100644 rpc_gen/rpc/user/user_init.go diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/hertz101.iml b/.idea/hertz101.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/hertz101.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ab5deec --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..d843f34 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0f3ffb5 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +export ROOT_MOD=github.com/suyiiyii/hertz101 + +.PHONY: gen-user +gen-user: + @cd app/user && cwgo server --type RPC --service user --module ${ROOT_MOD}/app/user --pass "-use ${ROOT_MOD}/rpc_gen/kitex_gen" -I ../../idl --idl ../../idl/user.proto + @cd rpc_gen && cwgo client --type RPC --service user --module ${ROOT_MOD}/rpc_gen --I ../idl --idl ../idl/user.proto \ No newline at end of file diff --git a/app/user/.gitignore b/app/user/.gitignore new file mode 100644 index 0000000..6881086 --- /dev/null +++ b/app/user/.gitignore @@ -0,0 +1,35 @@ +*.o +*.a +*.so +_obj +_test +*.[568vq] +[568vq].out +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* +_testmain.go +*.exe +*.exe~ +*.test +*.prof +*.rar +*.zip +*.gz +*.psd +*.bmd +*.cfg +*.pptx +*.log +*nohup.out +*settings.pyc +*.sublime-project +*.sublime-workspace +!.gitkeep +.DS_Store +/.idea +/.vscode +/output +*.local.yml diff --git a/app/user/biz/dal/init.go b/app/user/biz/dal/init.go new file mode 100644 index 0000000..46269a5 --- /dev/null +++ b/app/user/biz/dal/init.go @@ -0,0 +1,11 @@ +package dal + +import ( + "github.com/suyiiyii/hertz101/app/user/biz/dal/mysql" + "github.com/suyiiyii/hertz101/app/user/biz/dal/redis" +) + +func Init() { + redis.Init() + mysql.Init() +} diff --git a/app/user/biz/dal/mysql/init.go b/app/user/biz/dal/mysql/init.go new file mode 100644 index 0000000..b0be70d --- /dev/null +++ b/app/user/biz/dal/mysql/init.go @@ -0,0 +1,25 @@ +package mysql + +import ( + "github.com/suyiiyii/hertz101/app/user/conf" + + "gorm.io/driver/mysql" + "gorm.io/gorm" +) + +var ( + DB *gorm.DB + err error +) + +func Init() { + DB, err = gorm.Open(mysql.Open(conf.GetConf().MySQL.DSN), + &gorm.Config{ + PrepareStmt: true, + SkipDefaultTransaction: true, + }, + ) + if err != nil { + panic(err) + } +} diff --git a/app/user/biz/dal/redis/init.go b/app/user/biz/dal/redis/init.go new file mode 100644 index 0000000..f1d3929 --- /dev/null +++ b/app/user/biz/dal/redis/init.go @@ -0,0 +1,24 @@ +package redis + +import ( + "context" + + "github.com/redis/go-redis/v9" + "github.com/suyiiyii/hertz101/app/user/conf" +) + +var ( + RedisClient *redis.Client +) + +func Init() { + RedisClient = redis.NewClient(&redis.Options{ + Addr: conf.GetConf().Redis.Address, + Username: conf.GetConf().Redis.Username, + Password: conf.GetConf().Redis.Password, + DB: conf.GetConf().Redis.DB, + }) + if err := RedisClient.Ping(context.Background()).Err(); err != nil { + panic(err) + } +} diff --git a/app/user/biz/service/login.go b/app/user/biz/service/login.go new file mode 100644 index 0000000..2b3af1f --- /dev/null +++ b/app/user/biz/service/login.go @@ -0,0 +1,20 @@ +package service + +import ( + "context" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +type LoginService struct { + ctx context.Context +} // NewLoginService new LoginService +func NewLoginService(ctx context.Context) *LoginService { + return &LoginService{ctx: ctx} +} + +// Run create note info +func (s *LoginService) Run(req *user.LoginReq) (resp *user.LoginResp, err error) { + // Finish your business logic. + + return +} diff --git a/app/user/biz/service/login_test.go b/app/user/biz/service/login_test.go new file mode 100644 index 0000000..2c89b0c --- /dev/null +++ b/app/user/biz/service/login_test.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "testing" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +func TestLogin_Run(t *testing.T) { + ctx := context.Background() + s := NewLoginService(ctx) + // init req and assert value + + req := &user.LoginReq{} + resp, err := s.Run(req) + t.Logf("err: %v", err) + t.Logf("resp: %v", resp) + + // todo: edit your unit test + +} diff --git a/app/user/biz/service/register.go b/app/user/biz/service/register.go new file mode 100644 index 0000000..8b944c1 --- /dev/null +++ b/app/user/biz/service/register.go @@ -0,0 +1,20 @@ +package service + +import ( + "context" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +type RegisterService struct { + ctx context.Context +} // NewRegisterService new RegisterService +func NewRegisterService(ctx context.Context) *RegisterService { + return &RegisterService{ctx: ctx} +} + +// Run create note info +func (s *RegisterService) Run(req *user.RegisterResp) (resp *user.RegisterResp, err error) { + // Finish your business logic. + + return +} diff --git a/app/user/biz/service/register_test.go b/app/user/biz/service/register_test.go new file mode 100644 index 0000000..1c4979c --- /dev/null +++ b/app/user/biz/service/register_test.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "testing" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +func TestRegister_Run(t *testing.T) { + ctx := context.Background() + s := NewRegisterService(ctx) + // init req and assert value + + req := &user.RegisterResp{} + resp, err := s.Run(req) + t.Logf("err: %v", err) + t.Logf("resp: %v", resp) + + // todo: edit your unit test + +} diff --git a/app/user/build.sh b/app/user/build.sh new file mode 100644 index 0000000..f876e8e --- /dev/null +++ b/app/user/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +RUN_NAME="user" +mkdir -p output/bin output/conf +cp script/* output/ +cp -r conf/* output/conf +chmod +x output/bootstrap.sh +go build -o output/bin/${RUN_NAME} diff --git a/app/user/conf/conf.go b/app/user/conf/conf.go new file mode 100644 index 0000000..1f929e8 --- /dev/null +++ b/app/user/conf/conf.go @@ -0,0 +1,110 @@ +package conf + +import ( + "io/ioutil" + "os" + "path/filepath" + "sync" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/kr/pretty" + "gopkg.in/validator.v2" + "gopkg.in/yaml.v2" +) + +var ( + conf *Config + once sync.Once +) + +type Config struct { + Env string + Kitex Kitex `yaml:"kitex"` + MySQL MySQL `yaml:"mysql"` + Redis Redis `yaml:"redis"` + Registry Registry `yaml:"registry"` +} + +type MySQL struct { + DSN string `yaml:"dsn"` +} + +type Redis struct { + Address string `yaml:"address"` + Username string `yaml:"username"` + Password string `yaml:"password"` + DB int `yaml:"db"` +} + +type Kitex struct { + Service string `yaml:"service"` + Address string `yaml:"address"` + LogLevel string `yaml:"log_level"` + LogFileName string `yaml:"log_file_name"` + LogMaxSize int `yaml:"log_max_size"` + LogMaxBackups int `yaml:"log_max_backups"` + LogMaxAge int `yaml:"log_max_age"` +} + +type Registry struct { + RegistryAddress []string `yaml:"registry_address"` + Username string `yaml:"username"` + Password string `yaml:"password"` +} + +// GetConf gets configuration instance +func GetConf() *Config { + once.Do(initConf) + return conf +} + +func initConf() { + prefix := "conf" + confFileRelPath := filepath.Join(prefix, filepath.Join(GetEnv(), "conf.yaml")) + content, err := ioutil.ReadFile(confFileRelPath) + if err != nil { + panic(err) + } + conf = new(Config) + err = yaml.Unmarshal(content, conf) + if err != nil { + klog.Error("parse yaml error - %v", err) + panic(err) + } + if err := validator.Validate(conf); err != nil { + klog.Error("validate config error - %v", err) + panic(err) + } + conf.Env = GetEnv() + pretty.Printf("%+v\n", conf) +} + +func GetEnv() string { + e := os.Getenv("GO_ENV") + if len(e) == 0 { + return "test" + } + return e +} + +func LogLevel() klog.Level { + level := GetConf().Kitex.LogLevel + switch level { + case "trace": + return klog.LevelTrace + case "debug": + return klog.LevelDebug + case "info": + return klog.LevelInfo + case "notice": + return klog.LevelNotice + case "warn": + return klog.LevelWarn + case "error": + return klog.LevelError + case "fatal": + return klog.LevelFatal + default: + return klog.LevelInfo + } +} diff --git a/app/user/conf/dev/conf.yaml b/app/user/conf/dev/conf.yaml new file mode 100644 index 0000000..693f1b8 --- /dev/null +++ b/app/user/conf/dev/conf.yaml @@ -0,0 +1,23 @@ +kitex: + service: "user" + address: ":8888" + log_level: info + log_file_name: "log/kitex.log" + log_max_size: 10 + log_max_age: 3 + log_max_backups: 50 + +registry: + registry_address: + - 127.0.0.1:2379 + username: "" + password: "" + +mysql: + dsn: "gorm:gorm@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local" + +redis: + address: "127.0.0.1:6379" + username: "" + password: "" + db: 0 diff --git a/app/user/conf/online/conf.yaml b/app/user/conf/online/conf.yaml new file mode 100644 index 0000000..693f1b8 --- /dev/null +++ b/app/user/conf/online/conf.yaml @@ -0,0 +1,23 @@ +kitex: + service: "user" + address: ":8888" + log_level: info + log_file_name: "log/kitex.log" + log_max_size: 10 + log_max_age: 3 + log_max_backups: 50 + +registry: + registry_address: + - 127.0.0.1:2379 + username: "" + password: "" + +mysql: + dsn: "gorm:gorm@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local" + +redis: + address: "127.0.0.1:6379" + username: "" + password: "" + db: 0 diff --git a/app/user/conf/test/conf.yaml b/app/user/conf/test/conf.yaml new file mode 100644 index 0000000..693f1b8 --- /dev/null +++ b/app/user/conf/test/conf.yaml @@ -0,0 +1,23 @@ +kitex: + service: "user" + address: ":8888" + log_level: info + log_file_name: "log/kitex.log" + log_max_size: 10 + log_max_age: 3 + log_max_backups: 50 + +registry: + registry_address: + - 127.0.0.1:2379 + username: "" + password: "" + +mysql: + dsn: "gorm:gorm@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local" + +redis: + address: "127.0.0.1:6379" + username: "" + password: "" + db: 0 diff --git a/app/user/docker-compose.yaml b/app/user/docker-compose.yaml new file mode 100644 index 0000000..45be340 --- /dev/null +++ b/app/user/docker-compose.yaml @@ -0,0 +1,15 @@ +version: '3' +services: + mysql: + image: 'mysql:latest' + ports: + - 3306:3306 + environment: + - MYSQL_DATABASE=gorm + - MYSQL_USER=gorm + - MYSQL_PASSWORD=gorm + - MYSQL_RANDOM_ROOT_PASSWORD="yes" + redis: + image: 'redis:latest' + ports: + - 6379:6379 diff --git a/app/user/go.mod b/app/user/go.mod new file mode 100644 index 0000000..dc5d9d3 --- /dev/null +++ b/app/user/go.mod @@ -0,0 +1,54 @@ +module github.com/suyiiyii/hertz101/app/user + +go 1.23.4 + +replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 + +require ( + github.com/cloudwego/kitex v0.12.1 + github.com/kr/pretty v0.1.0 + gopkg.in/yaml.v2 v2.2.2 +) + +require ( + github.com/bytedance/gopkg v0.1.1 // indirect + github.com/bytedance/sonic v1.12.5 // indirect + github.com/bytedance/sonic/loader v0.2.0 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/configmanager v0.2.2 // indirect + github.com/cloudwego/dynamicgo v0.4.7-0.20241220085612-55704ea4ca8f // indirect + github.com/cloudwego/fastpb v0.0.5 // indirect + github.com/cloudwego/frugal v0.2.3 // indirect + github.com/cloudwego/gopkg v0.1.3 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect + github.com/cloudwego/runtimex v0.1.0 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/fatih/structtag v1.2.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/iancoleman/strcase v0.2.0 // indirect + github.com/jhump/protoreflect v1.8.2 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/tidwall/gjson v1.17.3 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.2.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect + google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/app/user/go.sum b/app/user/go.sum new file mode 100644 index 0000000..744c2c0 --- /dev/null +++ b/app/user/go.sum @@ -0,0 +1,50 @@ +github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= +github.com/cloudwego/dynamicgo v0.4.7-0.20241220085612-55704ea4ca8f h1:IERXjxDg3Pbatb5z/dR8Qr8XUA1FpDVa73BnwbeQ76U= +github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/kitex v0.12.1 h1:Ib+RWDRzXNz/9mObZmWasjFgrIVNrLSyvMveFDA2tTM= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/runtimex v0.1.0 h1:HG+WxWoj5/CDChDZ7D99ROwvSMkuNXAqt6hnhTTZDiI= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= +github.com/jhump/protoreflect v1.8.2 h1:k2xE7wcUomeqwY0LDCYA16y4WWfyTcMx5mKhk0d4ua0= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5 h1:uiS4zKYKJVj5F3ID+5iylfKPsEQmBEOucSD9Vgmn0i0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +golang.org/x/arch v0.2.0 h1:W1sUEHXiJTfjaFJ5SLo0N6lZn+0eO5gWD1MFeTGqQEY= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 h1:z+j74wi4yV+P7EtK9gPLGukOk7mFOy9wMQaC0wNb7eY= +google.golang.org/grpc v1.36.1 h1:cmUfbeGKnz9+2DD/UYsMQXeqbHZqZDs4eQwW0sFOpBY= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/app/user/handler.go b/app/user/handler.go new file mode 100644 index 0000000..c895b97 --- /dev/null +++ b/app/user/handler.go @@ -0,0 +1,24 @@ +package main + +import ( + "context" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" + "github.com/suyiiyii/hertz101/app/user/biz/service" +) + +// UserServiceImpl implements the last service interface defined in the IDL. +type UserServiceImpl struct{} + +// Register implements the UserServiceImpl interface. +func (s *UserServiceImpl) Register(ctx context.Context, req *user.RegisterResp) (resp *user.RegisterResp, err error) { + resp, err = service.NewRegisterService(ctx).Run(req) + + return resp, err +} + +// Login implements the UserServiceImpl interface. +func (s *UserServiceImpl) Login(ctx context.Context, req *user.LoginReq) (resp *user.LoginResp, err error) { + resp, err = service.NewLoginService(ctx).Run(req) + + return resp, err +} diff --git a/app/user/kitex_info.yaml b/app/user/kitex_info.yaml new file mode 100644 index 0000000..3a92f88 --- /dev/null +++ b/app/user/kitex_info.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'user' + ToolVersion: 'v0.9.1' diff --git a/app/user/main.go b/app/user/main.go new file mode 100644 index 0000000..b46244f --- /dev/null +++ b/app/user/main.go @@ -0,0 +1,59 @@ +package main + +import ( + "net" + "time" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/suyiiyii/hertz101/app/user/conf" + "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user/userservice" + "go.uber.org/zap/zapcore" + "gopkg.in/natefinch/lumberjack.v2" +) + +func main() { + opts := kitexInit() + + svr := userservice.NewServer(new(UserServiceImpl), opts...) + + err := svr.Run() + if err != nil { + klog.Error(err.Error()) + } +} + +func kitexInit() (opts []server.Option) { + // address + addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address) + if err != nil { + panic(err) + } + opts = append(opts, server.WithServiceAddr(addr)) + + // service info + opts = append(opts, server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ + ServiceName: conf.GetConf().Kitex.Service, + })) + + // klog + logger := kitexlogrus.NewLogger() + klog.SetLogger(logger) + klog.SetLevel(conf.LogLevel()) + asyncWriter := &zapcore.BufferedWriteSyncer{ + WS: zapcore.AddSync(&lumberjack.Logger{ + Filename: conf.GetConf().Kitex.LogFileName, + MaxSize: conf.GetConf().Kitex.LogMaxSize, + MaxBackups: conf.GetConf().Kitex.LogMaxBackups, + MaxAge: conf.GetConf().Kitex.LogMaxAge, + }), + FlushInterval: time.Minute, + } + klog.SetOutput(asyncWriter) + server.RegisterShutdownHook(func() { + asyncWriter.Sync() + }) + return +} diff --git a/app/user/readme.md b/app/user/readme.md new file mode 100644 index 0000000..f25d9fb --- /dev/null +++ b/app/user/readme.md @@ -0,0 +1,26 @@ +# *** Project + +## introduce + +- Use the [Kitex](https://github.com/cloudwego/kitex/) framework +- Generating the base code for unit tests. +- Provides basic config functions +- Provides the most basic MVC code hierarchy. + +## Directory structure + +| catalog | introduce | +| ---- | ---- | +| conf | Configuration files | +| main.go | Startup file | +| handler.go | Used for request processing return of response. | +| kitex_gen | kitex generated code | +| biz/service | The actual business logic. | +| biz/dal | Logic for operating the storage layer | + +## How to run + +```shell +sh build.sh +sh output/bootstrap.sh +``` diff --git a/app/user/script/bootstrap.sh b/app/user/script/bootstrap.sh new file mode 100644 index 0000000..f02db4c --- /dev/null +++ b/app/user/script/bootstrap.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) +echo "$CURDIR/bin/user" +exec "$CURDIR/bin/user" diff --git a/go.work b/go.work new file mode 100644 index 0000000..bc06546 --- /dev/null +++ b/go.work @@ -0,0 +1,6 @@ +go 1.23.4 + +use ( + app/user + rpc_gen +) diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..89eaac1 --- /dev/null +++ b/go.work.sum @@ -0,0 +1,45 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= +github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= +github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M= +github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= +github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad h1:EmNYJhPYy0pOFjCx2PrgtaBXmee0iUX9hLlxE1xHOJE= +github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf h1:vc7Dmrk4JwS0ZPS6WZvWlwDflgDTA26jItmbSj83nug= +github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE= +github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= +github.com/knz/go-libedit v1.10.1 h1:0pHpWtx9vcvC0xGZqEQlQdfSQs7WRlAjuPvk3fOZDCo= +github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= +github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3 h1:3f0nxAmdj/VoCGN/ijdMy7bj6SBagaqYg1B0hu8clMA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= +github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4 h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= +honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= +nullprogram.com/x/optparse v1.0.0 h1:xGFgVi5ZaWOnYdac2foDT3vg0ZZC9ErXFV57mr4OHrI= +rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= diff --git a/idl/user.proto b/idl/user.proto new file mode 100644 index 0000000..d8957ba --- /dev/null +++ b/idl/user.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package user; + +option go_package ="/user"; + +message RegisterReq { + string email = 1; + string password = 2; +} + +message RegisterResp { + int32 user_id = 1; +} + +message LoginReq { + string email = 1; + string password = 2; +} + +message LoginResp { + int32 user_id = 1; +} + +service UserService { + rpc Register (RegisterResp) returns (RegisterResp) {} + rpc Login (LoginReq) returns (LoginResp) {} +} \ No newline at end of file diff --git a/rpc_gen/go.mod b/rpc_gen/go.mod new file mode 100644 index 0000000..59d0be0 --- /dev/null +++ b/rpc_gen/go.mod @@ -0,0 +1,51 @@ +module github.com/suyiiyii/hertz101/rpc_gen + +go 1.23.4 + +replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 + +require ( + github.com/cloudwego/fastpb v0.0.5 + github.com/cloudwego/kitex v0.12.1 + google.golang.org/protobuf v1.33.0 +) + +require ( + github.com/bytedance/gopkg v0.1.1 // indirect + github.com/bytedance/sonic v1.12.5 // indirect + github.com/bytedance/sonic/loader v0.2.0 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/configmanager v0.2.2 // indirect + github.com/cloudwego/dynamicgo v0.4.7-0.20241220085612-55704ea4ca8f // indirect + github.com/cloudwego/frugal v0.2.3 // indirect + github.com/cloudwego/gopkg v0.1.3 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/cloudwego/localsession v0.1.1 // indirect + github.com/cloudwego/netpoll v0.6.5 // indirect + github.com/cloudwego/runtimex v0.1.0 // indirect + github.com/cloudwego/thriftgo v0.3.18 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/fatih/structtag v1.2.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/iancoleman/strcase v0.2.0 // indirect + github.com/jhump/protoreflect v1.8.2 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/tidwall/gjson v1.17.3 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.2.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/rpc_gen/go.sum b/rpc_gen/go.sum new file mode 100644 index 0000000..7528fda --- /dev/null +++ b/rpc_gen/go.sum @@ -0,0 +1,257 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/bytedance/gopkg v0.0.0-20230728082804-614d0af6619b/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= +github.com/bytedance/gopkg v0.1.0/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= +github.com/bytedance/gopkg v0.1.1 h1:3azzgSkiaw79u24a+w9arfH8OfnQQ4MHUt9lJFREEaE= +github.com/bytedance/gopkg v0.1.1/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= +github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= +github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/configmanager v0.2.2 h1:sVrJB8gWYTlPV2OS3wcgJSO9F2/9Zbkmcm1Z7jempOU= +github.com/cloudwego/configmanager v0.2.2/go.mod h1:ppiyU+5TPLonE8qMVi/pFQk2eL3Q4P7d4hbiNJn6jwI= +github.com/cloudwego/dynamicgo v0.4.7-0.20241220085612-55704ea4ca8f h1:IERXjxDg3Pbatb5z/dR8Qr8XUA1FpDVa73BnwbeQ76U= +github.com/cloudwego/dynamicgo v0.4.7-0.20241220085612-55704ea4ca8f/go.mod h1:DknfxjIMuGvXow409bS/AWycXONdc02HECBL0qpNqTY= +github.com/cloudwego/fastpb v0.0.5 h1:vYnBPsfbAtU5TVz5+f9UTlmSCixG9F9vRwaqE0mZPZU= +github.com/cloudwego/fastpb v0.0.5/go.mod h1:Bho7aAKBUtT9RPD2cNVkTdx4yQumfSv3If7wYnm1izk= +github.com/cloudwego/frugal v0.2.3 h1:t1hhhAi8lXcx7Ncs4PR1pSZ90vlDU1cy5K2btDMFpoA= +github.com/cloudwego/frugal v0.2.3/go.mod h1:nC1U47gswLRiaxv6dybrhZvsDGCfQP9RGiiWC73CnoI= +github.com/cloudwego/gopkg v0.1.3 h1:y9VA5Zn5yqd1+QBV9aB0Zxy56JlAS7x4ZUoED/vJdxA= +github.com/cloudwego/gopkg v0.1.3/go.mod h1:FQuXsRWRsSqJLsMVd5SYzp8/Z1y5gXKnVvRrWUOsCMI= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/cloudwego/kitex v0.12.1 h1:Ib+RWDRzXNz/9mObZmWasjFgrIVNrLSyvMveFDA2tTM= +github.com/cloudwego/kitex v0.12.1/go.mod h1:o9Vaz/Kpu0uAj7go0+0jq3hr4e+Im/BunlmhnUAyqkQ= +github.com/cloudwego/localsession v0.1.1 h1:tbK7laDVrYfFDXoBXo4uCGMAxU4qmz2dDm8d4BGBnDo= +github.com/cloudwego/localsession v0.1.1/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.6.5 h1:6E/BWhSzQoyLg9Kx/4xiMdIIpovzwBtXvuqSqaTUzDQ= +github.com/cloudwego/netpoll v0.6.5/go.mod h1:BtM+GjKTdwKoC8IOzD08/+8eEn2gYoiNLipFca6BVXQ= +github.com/cloudwego/runtimex v0.1.0 h1:HG+WxWoj5/CDChDZ7D99ROwvSMkuNXAqt6hnhTTZDiI= +github.com/cloudwego/runtimex v0.1.0/go.mod h1:23vL/HGV0W8nSCHbe084AgEBdDV4rvXenEUMnUNvUd8= +github.com/cloudwego/thriftgo v0.3.18 h1:gnr1vz7G3RbwwCK9AMKHZf63VYGa7ene6WbI9VrBJSw= +github.com/cloudwego/thriftgo v0.3.18/go.mod h1:AdLEJJVGW/ZJYvkkYAZf5SaJH+pA3OyC801WSwqcBwI= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= +github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/jhump/protoreflect v1.8.2 h1:k2xE7wcUomeqwY0LDCYA16y4WWfyTcMx5mKhk0d4ua0= +github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5 h1:uiS4zKYKJVj5F3ID+5iylfKPsEQmBEOucSD9Vgmn0i0= +github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5/go.mod h1:I8AX+yW//L8Hshx6+a1m3bYkwXkpsVjA2795vP4f4oQ= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= +github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.2.0 h1:W1sUEHXiJTfjaFJ5SLo0N6lZn+0eO5gWD1MFeTGqQEY= +golang.org/x/arch v0.2.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 h1:z+j74wi4yV+P7EtK9gPLGukOk7mFOy9wMQaC0wNb7eY= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.36.1 h1:cmUfbeGKnz9+2DD/UYsMQXeqbHZqZDs4eQwW0sFOpBY= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/rpc_gen/kitex_gen/user/user.pb.fast.go b/rpc_gen/kitex_gen/user/user.pb.fast.go new file mode 100644 index 0000000..69de238 --- /dev/null +++ b/rpc_gen/kitex_gen/user/user.pb.fast.go @@ -0,0 +1,315 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package user + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *RegisterReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_RegisterReq[number], err) +} + +func (x *RegisterReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Email, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *RegisterReq) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.Password, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *RegisterResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_RegisterResp[number], err) +} + +func (x *RegisterResp) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.UserId, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *LoginReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_LoginReq[number], err) +} + +func (x *LoginReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Email, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *LoginReq) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.Password, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *LoginResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_LoginResp[number], err) +} + +func (x *LoginResp) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.UserId, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *RegisterReq) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *RegisterReq) fastWriteField1(buf []byte) (offset int) { + if x.Email == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetEmail()) + return offset +} + +func (x *RegisterReq) fastWriteField2(buf []byte) (offset int) { + if x.Password == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.GetPassword()) + return offset +} + +func (x *RegisterResp) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *RegisterResp) fastWriteField1(buf []byte) (offset int) { + if x.UserId == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 1, x.GetUserId()) + return offset +} + +func (x *LoginReq) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + return offset +} + +func (x *LoginReq) fastWriteField1(buf []byte) (offset int) { + if x.Email == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetEmail()) + return offset +} + +func (x *LoginReq) fastWriteField2(buf []byte) (offset int) { + if x.Password == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.GetPassword()) + return offset +} + +func (x *LoginResp) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *LoginResp) fastWriteField1(buf []byte) (offset int) { + if x.UserId == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 1, x.GetUserId()) + return offset +} + +func (x *RegisterReq) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *RegisterReq) sizeField1() (n int) { + if x.Email == "" { + return n + } + n += fastpb.SizeString(1, x.GetEmail()) + return n +} + +func (x *RegisterReq) sizeField2() (n int) { + if x.Password == "" { + return n + } + n += fastpb.SizeString(2, x.GetPassword()) + return n +} + +func (x *RegisterResp) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *RegisterResp) sizeField1() (n int) { + if x.UserId == 0 { + return n + } + n += fastpb.SizeInt32(1, x.GetUserId()) + return n +} + +func (x *LoginReq) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + return n +} + +func (x *LoginReq) sizeField1() (n int) { + if x.Email == "" { + return n + } + n += fastpb.SizeString(1, x.GetEmail()) + return n +} + +func (x *LoginReq) sizeField2() (n int) { + if x.Password == "" { + return n + } + n += fastpb.SizeString(2, x.GetPassword()) + return n +} + +func (x *LoginResp) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *LoginResp) sizeField1() (n int) { + if x.UserId == 0 { + return n + } + n += fastpb.SizeInt32(1, x.GetUserId()) + return n +} + +var fieldIDToName_RegisterReq = map[int32]string{ + 1: "Email", + 2: "Password", +} + +var fieldIDToName_RegisterResp = map[int32]string{ + 1: "UserId", +} + +var fieldIDToName_LoginReq = map[int32]string{ + 1: "Email", + 2: "Password", +} + +var fieldIDToName_LoginResp = map[int32]string{ + 1: "UserId", +} diff --git a/rpc_gen/kitex_gen/user/user.pb.go b/rpc_gen/kitex_gen/user/user.pb.go new file mode 100644 index 0000000..0b920b9 --- /dev/null +++ b/rpc_gen/kitex_gen/user/user.pb.go @@ -0,0 +1,371 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.29.2 +// source: user.proto + +package user + +import ( + context "context" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RegisterReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *RegisterReq) Reset() { + *x = RegisterReq{} + if protoimpl.UnsafeEnabled { + mi := &file_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterReq) ProtoMessage() {} + +func (x *RegisterReq) ProtoReflect() protoreflect.Message { + mi := &file_user_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterReq.ProtoReflect.Descriptor instead. +func (*RegisterReq) Descriptor() ([]byte, []int) { + return file_user_proto_rawDescGZIP(), []int{0} +} + +func (x *RegisterReq) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *RegisterReq) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type RegisterResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` +} + +func (x *RegisterResp) Reset() { + *x = RegisterResp{} + if protoimpl.UnsafeEnabled { + mi := &file_user_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResp) ProtoMessage() {} + +func (x *RegisterResp) ProtoReflect() protoreflect.Message { + mi := &file_user_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterResp.ProtoReflect.Descriptor instead. +func (*RegisterResp) Descriptor() ([]byte, []int) { + return file_user_proto_rawDescGZIP(), []int{1} +} + +func (x *RegisterResp) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +type LoginReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *LoginReq) Reset() { + *x = LoginReq{} + if protoimpl.UnsafeEnabled { + mi := &file_user_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginReq) ProtoMessage() {} + +func (x *LoginReq) ProtoReflect() protoreflect.Message { + mi := &file_user_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead. +func (*LoginReq) Descriptor() ([]byte, []int) { + return file_user_proto_rawDescGZIP(), []int{2} +} + +func (x *LoginReq) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *LoginReq) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type LoginResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` +} + +func (x *LoginResp) Reset() { + *x = LoginResp{} + if protoimpl.UnsafeEnabled { + mi := &file_user_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResp) ProtoMessage() {} + +func (x *LoginResp) ProtoReflect() protoreflect.Message { + mi := &file_user_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginResp.ProtoReflect.Descriptor instead. +func (*LoginResp) Descriptor() ([]byte, []int) { + return file_user_proto_rawDescGZIP(), []int{3} +} + +func (x *LoginResp) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +var File_user_proto protoreflect.FileDescriptor + +var file_user_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, + 0x65, 0x72, 0x22, 0x3f, 0x0a, 0x0b, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x22, 0x27, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x3c, 0x0a, 0x08, + 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x24, 0x0a, 0x09, 0x4c, 0x6f, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x32, 0x6f, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x34, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x75, 0x73, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x1a, + 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2a, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0e, + 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0f, + 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, + 0x00, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x73, 0x75, 0x79, 0x69, 0x69, 0x79, 0x69, 0x69, 0x2f, 0x68, 0x65, 0x72, 0x74, 0x7a, 0x31, 0x30, + 0x31, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, + 0x67, 0x65, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_user_proto_rawDescOnce sync.Once + file_user_proto_rawDescData = file_user_proto_rawDesc +) + +func file_user_proto_rawDescGZIP() []byte { + file_user_proto_rawDescOnce.Do(func() { + file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData) + }) + return file_user_proto_rawDescData +} + +var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_user_proto_goTypes = []interface{}{ + (*RegisterReq)(nil), // 0: user.RegisterReq + (*RegisterResp)(nil), // 1: user.RegisterResp + (*LoginReq)(nil), // 2: user.LoginReq + (*LoginResp)(nil), // 3: user.LoginResp +} +var file_user_proto_depIdxs = []int32{ + 1, // 0: user.UserService.Register:input_type -> user.RegisterResp + 2, // 1: user.UserService.Login:input_type -> user.LoginReq + 1, // 2: user.UserService.Register:output_type -> user.RegisterResp + 3, // 3: user.UserService.Login:output_type -> user.LoginResp + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_user_proto_init() } +func file_user_proto_init() { + if File_user_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_user_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_user_proto_goTypes, + DependencyIndexes: file_user_proto_depIdxs, + MessageInfos: file_user_proto_msgTypes, + }.Build() + File_user_proto = out.File + file_user_proto_rawDesc = nil + file_user_proto_goTypes = nil + file_user_proto_depIdxs = nil +} + +var _ context.Context + +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +type UserService interface { + Register(ctx context.Context, req *RegisterResp) (res *RegisterResp, err error) + Login(ctx context.Context, req *LoginReq) (res *LoginResp, err error) +} diff --git a/rpc_gen/kitex_gen/user/userservice/client.go b/rpc_gen/kitex_gen/user/userservice/client.go new file mode 100644 index 0000000..7fe83a2 --- /dev/null +++ b/rpc_gen/kitex_gen/user/userservice/client.go @@ -0,0 +1,55 @@ +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package userservice + +import ( + "context" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Register(ctx context.Context, Req *user.RegisterResp, callOptions ...callopt.Option) (r *user.RegisterResp, err error) + Login(ctx context.Context, Req *user.LoginReq, callOptions ...callopt.Option) (r *user.LoginResp, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kUserServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kUserServiceClient struct { + *kClient +} + +func (p *kUserServiceClient) Register(ctx context.Context, Req *user.RegisterResp, callOptions ...callopt.Option) (r *user.RegisterResp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Register(ctx, Req) +} + +func (p *kUserServiceClient) Login(ctx context.Context, Req *user.LoginReq, callOptions ...callopt.Option) (r *user.LoginResp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Login(ctx, Req) +} diff --git a/rpc_gen/kitex_gen/user/userservice/invoker.go b/rpc_gen/kitex_gen/user/userservice/invoker.go new file mode 100644 index 0000000..1a93f5e --- /dev/null +++ b/rpc_gen/kitex_gen/user/userservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package userservice + +import ( + server "github.com/cloudwego/kitex/server" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler user.UserService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/rpc_gen/kitex_gen/user/userservice/server.go b/rpc_gen/kitex_gen/user/userservice/server.go new file mode 100644 index 0000000..b54e3b7 --- /dev/null +++ b/rpc_gen/kitex_gen/user/userservice/server.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.9.1. DO NOT EDIT. +package userservice + +import ( + server "github.com/cloudwego/kitex/server" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler user.UserService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} + +func RegisterService(svr server.Server, handler user.UserService, opts ...server.RegisterOption) error { + return svr.RegisterService(serviceInfo(), handler, opts...) +} diff --git a/rpc_gen/kitex_gen/user/userservice/userservice.go b/rpc_gen/kitex_gen/user/userservice/userservice.go new file mode 100644 index 0000000..f38f420 --- /dev/null +++ b/rpc_gen/kitex_gen/user/userservice/userservice.go @@ -0,0 +1,432 @@ +// Code generated by Kitex v0.9.1. DO NOT EDIT. + +package userservice + +import ( + "context" + "errors" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" + proto "google.golang.org/protobuf/proto" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Register": kitex.NewMethodInfo( + registerHandler, + newRegisterArgs, + newRegisterResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), + "Login": kitex.NewMethodInfo( + loginHandler, + newLoginArgs, + newLoginResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), +} + +var ( + userServiceServiceInfo = NewServiceInfo() + userServiceServiceInfoForClient = NewServiceInfoForClient() + userServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return userServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return userServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return userServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "UserService" + handlerType := (*user.UserService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "user", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Protobuf, + KiteXGenVersion: "v0.9.1", + Extra: extra, + } + return svcInfo +} + +func registerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(user.RegisterResp) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(user.UserService).Register(ctx, req) + if err != nil { + return err + } + return st.SendMsg(resp) + case *RegisterArgs: + success, err := handler.(user.UserService).Register(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*RegisterResult) + realResult.Success = success + return nil + default: + return errInvalidMessageType + } +} +func newRegisterArgs() interface{} { + return &RegisterArgs{} +} + +func newRegisterResult() interface{} { + return &RegisterResult{} +} + +type RegisterArgs struct { + Req *user.RegisterResp +} + +func (p *RegisterArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(user.RegisterResp) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *RegisterArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *RegisterArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *RegisterArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *RegisterArgs) Unmarshal(in []byte) error { + msg := new(user.RegisterResp) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var RegisterArgs_Req_DEFAULT *user.RegisterResp + +func (p *RegisterArgs) GetReq() *user.RegisterResp { + if !p.IsSetReq() { + return RegisterArgs_Req_DEFAULT + } + return p.Req +} + +func (p *RegisterArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *RegisterArgs) GetFirstArgument() interface{} { + return p.Req +} + +type RegisterResult struct { + Success *user.RegisterResp +} + +var RegisterResult_Success_DEFAULT *user.RegisterResp + +func (p *RegisterResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(user.RegisterResp) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *RegisterResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *RegisterResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *RegisterResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *RegisterResult) Unmarshal(in []byte) error { + msg := new(user.RegisterResp) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *RegisterResult) GetSuccess() *user.RegisterResp { + if !p.IsSetSuccess() { + return RegisterResult_Success_DEFAULT + } + return p.Success +} + +func (p *RegisterResult) SetSuccess(x interface{}) { + p.Success = x.(*user.RegisterResp) +} + +func (p *RegisterResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *RegisterResult) GetResult() interface{} { + return p.Success +} + +func loginHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(user.LoginReq) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(user.UserService).Login(ctx, req) + if err != nil { + return err + } + return st.SendMsg(resp) + case *LoginArgs: + success, err := handler.(user.UserService).Login(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*LoginResult) + realResult.Success = success + return nil + default: + return errInvalidMessageType + } +} +func newLoginArgs() interface{} { + return &LoginArgs{} +} + +func newLoginResult() interface{} { + return &LoginResult{} +} + +type LoginArgs struct { + Req *user.LoginReq +} + +func (p *LoginArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(user.LoginReq) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *LoginArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *LoginArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *LoginArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *LoginArgs) Unmarshal(in []byte) error { + msg := new(user.LoginReq) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var LoginArgs_Req_DEFAULT *user.LoginReq + +func (p *LoginArgs) GetReq() *user.LoginReq { + if !p.IsSetReq() { + return LoginArgs_Req_DEFAULT + } + return p.Req +} + +func (p *LoginArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *LoginArgs) GetFirstArgument() interface{} { + return p.Req +} + +type LoginResult struct { + Success *user.LoginResp +} + +var LoginResult_Success_DEFAULT *user.LoginResp + +func (p *LoginResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(user.LoginResp) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *LoginResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *LoginResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *LoginResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *LoginResult) Unmarshal(in []byte) error { + msg := new(user.LoginResp) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *LoginResult) GetSuccess() *user.LoginResp { + if !p.IsSetSuccess() { + return LoginResult_Success_DEFAULT + } + return p.Success +} + +func (p *LoginResult) SetSuccess(x interface{}) { + p.Success = x.(*user.LoginResp) +} + +func (p *LoginResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *LoginResult) GetResult() interface{} { + return p.Success +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Register(ctx context.Context, Req *user.RegisterResp) (r *user.RegisterResp, err error) { + var _args RegisterArgs + _args.Req = Req + var _result RegisterResult + if err = p.c.Call(ctx, "Register", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) Login(ctx context.Context, Req *user.LoginReq) (r *user.LoginResp, err error) { + var _args LoginArgs + _args.Req = Req + var _result LoginResult + if err = p.c.Call(ctx, "Login", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/rpc_gen/rpc/user/user_client.go b/rpc_gen/rpc/user/user_client.go new file mode 100644 index 0000000..f7af311 --- /dev/null +++ b/rpc_gen/rpc/user/user_client.go @@ -0,0 +1,50 @@ +package user + +import ( + "context" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" +) + +type RPCClient interface { + KitexClient() userservice.Client + Service() string + Register(ctx context.Context, Req *user.RegisterResp, callOptions ...callopt.Option) (r *user.RegisterResp, err error) + Login(ctx context.Context, Req *user.LoginReq, callOptions ...callopt.Option) (r *user.LoginResp, err error) +} + +func NewRPCClient(dstService string, opts ...client.Option) (RPCClient, error) { + kitexClient, err := userservice.NewClient(dstService, opts...) + if err != nil { + return nil, err + } + cli := &clientImpl{ + service: dstService, + kitexClient: kitexClient, + } + + return cli, nil +} + +type clientImpl struct { + service string + kitexClient userservice.Client +} + +func (c *clientImpl) Service() string { + return c.service +} + +func (c *clientImpl) KitexClient() userservice.Client { + return c.kitexClient +} + +func (c *clientImpl) Register(ctx context.Context, Req *user.RegisterResp, callOptions ...callopt.Option) (r *user.RegisterResp, err error) { + return c.kitexClient.Register(ctx, Req, callOptions...) +} + +func (c *clientImpl) Login(ctx context.Context, Req *user.LoginReq, callOptions ...callopt.Option) (r *user.LoginResp, err error) { + return c.kitexClient.Login(ctx, Req, callOptions...) +} diff --git a/rpc_gen/rpc/user/user_default.go b/rpc_gen/rpc/user/user_default.go new file mode 100644 index 0000000..58f5aba --- /dev/null +++ b/rpc_gen/rpc/user/user_default.go @@ -0,0 +1,26 @@ +package user + +import ( + "context" + "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/pkg/klog" + user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user" +) + +func Register(ctx context.Context, req *user.RegisterResp, callOptions ...callopt.Option) (resp *user.RegisterResp, err error) { + resp, err = defaultClient.Register(ctx, req, callOptions...) + if err != nil { + klog.CtxErrorf(ctx, "Register call failed,err =%+v", err) + return nil, err + } + return resp, nil +} + +func Login(ctx context.Context, req *user.LoginReq, callOptions ...callopt.Option) (resp *user.LoginResp, err error) { + resp, err = defaultClient.Login(ctx, req, callOptions...) + if err != nil { + klog.CtxErrorf(ctx, "Login call failed,err =%+v", err) + return nil, err + } + return resp, nil +} diff --git a/rpc_gen/rpc/user/user_init.go b/rpc_gen/rpc/user/user_init.go new file mode 100644 index 0000000..6ef1e15 --- /dev/null +++ b/rpc_gen/rpc/user/user_init.go @@ -0,0 +1,40 @@ +package user + +import ( + "sync" + + "github.com/cloudwego/kitex/client" +) + +var ( + // todo edit custom config + defaultClient RPCClient + defaultDstService = "user" + defaultClientOpts = []client.Option{ + client.WithHostPorts("127.0.0.1:8888"), + } + once sync.Once +) + +func init() { + DefaultClient() +} + +func DefaultClient() RPCClient { + once.Do(func() { + defaultClient = newClient(defaultDstService, defaultClientOpts...) + }) + return defaultClient +} + +func newClient(dstService string, opts ...client.Option) RPCClient { + c, err := NewRPCClient(dstService, opts...) + if err != nil { + panic("failed to init client: " + err.Error()) + } + return c +} + +func InitClient(dstService string, opts ...client.Option) { + defaultClient = newClient(dstService, opts...) +}