From d455c068e3b1d57352b921d361b93c7cd1435a6f Mon Sep 17 00:00:00 2001 From: fgy Date: Thu, 3 Aug 2023 20:31:08 +0800 Subject: [PATCH 1/8] feat: add hex --- cmd/static/server_flags.go | 1 + config/argument.go | 1 + config/server.go | 1 + pkg/server/kitex.go | 190 +++++++++++++++++++++++++++++++++++++ pkg/server/server.go | 18 ++++ 5 files changed, 211 insertions(+) diff --git a/cmd/static/server_flags.go b/cmd/static/server_flags.go index 3ba199d8..1cd2c3ca 100644 --- a/cmd/static/server_flags.go +++ b/cmd/static/server_flags.go @@ -34,5 +34,6 @@ func serverFlags() []cli.Flag { &cli.StringSliceFlag{Name: config.ProtoSearchPath, Aliases: []string{"I"}, Usage: "Add an IDL search path for includes. (Valid only if idl is protobuf)"}, &cli.StringSliceFlag{Name: config.Pass, Usage: "pass param to hz or kitex"}, &cli.BoolFlag{Name: config.Verbose, Usage: "Turn on verbose mode."}, + &cli.BoolFlag{Name: config.HexTag, Usage: "Add HTTP listen for Kitex.", Destination: &globalArgs.Hex}, } } diff --git a/config/argument.go b/config/argument.go index b01b78cf..4c72bc85 100644 --- a/config/argument.go +++ b/config/argument.go @@ -113,4 +113,5 @@ const ( Signable = "signable" IndexTag = "index_tag" TypeTag = "type_tag" + HexTag = "hex" ) diff --git a/config/server.go b/config/server.go index 8d162a4e..ba6a63b1 100644 --- a/config/server.go +++ b/config/server.go @@ -29,6 +29,7 @@ type ServerArgument struct { Template string SliceParam *SliceParam Verbose bool + Hex bool // add http listen for kitex Cwd string GoSrc string diff --git a/pkg/server/kitex.go b/pkg/server/kitex.go index a6490207..a7a4571b 100644 --- a/pkg/server/kitex.go +++ b/pkg/server/kitex.go @@ -17,18 +17,26 @@ package server import ( + "bytes" "flag" "fmt" + "go/ast" + "go/parser" + "go/printer" + "go/token" "os" "os/exec" "path" "path/filepath" "strings" + "text/template" "github.com/cloudwego/cwgo/config" "github.com/cloudwego/cwgo/pkg/common/utils" "github.com/cloudwego/cwgo/pkg/consts" "github.com/cloudwego/cwgo/tpl" + hzConfig "github.com/cloudwego/hertz/cmd/hz/config" + "github.com/cloudwego/hertz/cmd/hz/meta" "github.com/cloudwego/kitex" kargs "github.com/cloudwego/kitex/tool/cmd/kitex/args" "github.com/cloudwego/kitex/tool/internal_pkg/generator" @@ -222,3 +230,185 @@ func replaceThriftVersion(args *kargs.Arguments) { log.Warn("Adding apache/thrift@v0.13.0 to go.mod for generated code ..........", res) } } + +func hzArgsForHex(c *config.ServerArgument) (*hzConfig.Argument, error) { + utils.SetHzVerboseLog(c.Verbose) + hzArgs := hzConfig.NewArgument() + err := convertHzArgument(c, hzArgs) + if err != nil { + return nil, err + } + hzArgs.CmdType = meta.CmdUpdate // update command is enough for hex + // these options are aligned with the kitex + hzArgs.ThriftOptions = append(hzArgs.ThriftOptions, "naming_style=golint", "ignore_initialisms", "gen_setter", "gen_deep_equal", "compatible_names", "frugal_tag") + hzArgs.ModelDir = "kitex_gen" + if hzArgs.CustomizePackage == path.Join(tpl.HertzDir, "server", config.Standard, packageLayoutFile) { + hzArgs.CustomizePackage = "" // disable the default hertz template for hex + } + return hzArgs, nil +} + +func generateHexFile(c *config.ServerArgument) error { + tmplContent := `package main + +import ( + "context" + "errors" + "fmt" + "net" + "regexp" + + "github.com/cloudwego/hertz/pkg/app" + hertzServer "github.com/cloudwego/hertz/pkg/app/server" + "github.com/cloudwego/hertz/pkg/common/utils" + "github.com/cloudwego/hertz/pkg/network" + "github.com/cloudwego/hertz/pkg/protocol/consts" + "github.com/cloudwego/hertz/pkg/route" + "github.com/cloudwego/kitex/pkg/endpoint" + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/remote" + "github.com/cloudwego/kitex/pkg/remote/trans/detection" + "github.com/cloudwego/kitex/pkg/remote/trans/netpoll" + "github.com/cloudwego/kitex/pkg/remote/trans/nphttp2" + "{{$.ProjPackage}}/biz/router" +) + +type mixTransHandlerFactory struct { + originFactory remote.ServerTransHandlerFactory +} + +type transHandler struct { + remote.ServerTransHandler +} + +// SetInvokeHandleFunc is used to set invoke handle func. +func (t *transHandler) SetInvokeHandleFunc(inkHdlFunc endpoint.Endpoint) { + t.ServerTransHandler.(remote.InvokeHandleFuncSetter).SetInvokeHandleFunc(inkHdlFunc) +} + +func (m mixTransHandlerFactory) NewTransHandler(opt *remote.ServerOption) (remote.ServerTransHandler, error) { + var kitexOrigin remote.ServerTransHandler + var err error + + if m.originFactory != nil { + kitexOrigin, err = m.originFactory.NewTransHandler(opt) + } else { + // if no customized factory just use the default factory under detection pkg. + kitexOrigin, err = detection.NewSvrTransHandlerFactory(netpoll.NewSvrTransHandlerFactory(), nphttp2.NewSvrTransHandlerFactory()).NewTransHandler(opt) + } + if err != nil { + return nil, err + } + return &transHandler{ServerTransHandler: kitexOrigin}, nil +} + +var httpReg = regexp.MustCompile(` + "`^(?:GET |POST|PUT|DELE|HEAD|OPTI|CONN|TRAC|PATC)$`" + `) + +func (t *transHandler) OnRead(ctx context.Context, conn net.Conn) error { + c, ok := conn.(network.Conn) + if ok { + pre, _ := c.Peek(4) + if httpReg.Match(pre) { + klog.Info("using Hertz to process request") + err := hertzEngine.Serve(ctx, c) + if err != nil { + err = errors.New(fmt.Sprintf("HERTZ: %s", err.Error())) + } + return err + } + } + return t.ServerTransHandler.OnRead(ctx, conn) +} + +func initHertz() *route.Engine { + h := hertzServer.New() + + // add a ping route to test + h.GET("/ping", func(c context.Context, ctx *app.RequestContext) { + ctx.JSON(consts.StatusOK, utils.H{"ping": "pong"}) + }) + + router.GeneratedRegister(h) + err := h.Engine.Init() + if err != nil { + panic(err) + } + return h.Engine +} + +var hertzEngine *route.Engine + +func init() { + hertzEngine = initHertz() +} + +` + tmpl := template.Must(template.New("hex_trans_handler").Parse(tmplContent)) + file, err := os.Create("hex_trans_handler.go") + if err != nil { + return err + } + defer file.Close() + return tmpl.Execute(file, map[string]string{ + "ProjPackage": c.GoMod, + }) +} + +func addHexOptions() error { + filePath := "main.go" + content, err := os.ReadFile(filePath) + if err != nil { + return err + } + if bytes.Contains(content, []byte("server.WithTransHandlerFactory(&mixTransHandlerFactory{nil})")) { + return nil + } + fset := token.NewFileSet() + astFile, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments) + if err != nil { + return err + } + found, err := insertCodeInFunction(astFile, "kitexInit", "opts", "append(opts,server.WithTransHandlerFactory(&mixTransHandlerFactory{nil}))") + if err != nil { + return err + } + if !found { + return nil + } + outputFile, err := os.Create("main.go") + if err != nil { + return err + } + defer outputFile.Close() + err = printer.Fprint(outputFile, fset, astFile) + if err != nil { + return err + } + + return nil +} + +func insertCodeInFunction(file *ast.File, functionName, left, right string) (bool, error) { + for _, decl := range file.Decls { + funcDecl, ok := decl.(*ast.FuncDecl) + if !ok { + continue + } + if funcDecl.Name.Name == functionName { + insertedStmt, err := parser.ParseExpr(right) + if err != nil { + return false, err + } + + assignStmt := &ast.AssignStmt{ + Tok: token.ASSIGN, + Lhs: []ast.Expr{ast.NewIdent(left)}, + Rhs: []ast.Expr{insertedStmt}, + } + + funcDecl.Body.List = append([]ast.Stmt{assignStmt}, funcDecl.Body.List...) + return true, nil + } + } + return false, nil +} diff --git a/pkg/server/server.go b/pkg/server/server.go index 4f8dda12..b84b5e53 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -66,6 +66,24 @@ func Server(c *config.ServerArgument) error { } os.Exit(1) } + if c.Hex { // add http listen for kitex + hzArgs, err := hzArgsForHex(c) + if err != nil { + return err + } + err = app.TriggerPlugin(hzArgs) + if err != nil { + return err + } + err = generateHexFile(c) + if err != nil { + return err + } + err = addHexOptions() + if err != nil { + log.Warn("please add \"opts = append(opts,server.WithTransHandlerFactory(&mixTransHandlerFactory{nil}))\", to your kitex options") + } + } replaceThriftVersion(&args) case config.HTTP: args := hzConfig.NewArgument() From 83c0b3d9605c7c46165118e62937cce393c79766 Mon Sep 17 00:00:00 2001 From: fgy Date: Thu, 3 Aug 2023 20:39:20 +0800 Subject: [PATCH 2/8] feat: add example --- example/hex/.gitignore | 35 + example/hex/Makefile | 6 + example/hex/biz/dal/init.go | 11 + example/hex/biz/dal/mysql/init.go | 25 + example/hex/biz/dal/redis/init.go | 24 + .../handler/hello/example/hello_service.go | 27 + example/hex/biz/router/hello/example/hello.go | 21 + .../biz/router/hello/example/middleware.go | 17 + example/hex/biz/router/register.go | 14 + example/hex/biz/service/hello_method.go | 20 + example/hex/biz/service/hello_method_test.go | 24 + example/hex/build.sh | 8 + example/hex/conf/conf.go | 114 +++ example/hex/conf/dev/conf.yaml | 22 + example/hex/conf/online/conf.yaml | 22 + example/hex/conf/test/conf.yaml | 22 + example/hex/docker-compose.yaml | 15 + example/hex/go.mod | 67 ++ example/hex/go.sum | 443 ++++++++++ example/hex/handler.go | 17 + example/hex/hex_trans_handler.go | 93 ++ example/hex/idl/hello.thrift | 15 + example/hex/kitex_gen/hello/example/hello.go | 814 ++++++++++++++++++ .../hello/example/helloservice/client.go | 49 ++ .../example/helloservice/helloservice.go | 74 ++ .../hello/example/helloservice/invoker.go | 24 + .../hello/example/helloservice/server.go | 20 + .../hex/kitex_gen/hello/example/k-consts.go | 4 + .../hex/kitex_gen/hello/example/k-hello.go | 550 ++++++++++++ example/hex/kitex_info.yaml | 3 + example/hex/main.go | 56 ++ example/hex/readme.md | 26 + example/hex/script/bootstrap.sh | 4 + 33 files changed, 2686 insertions(+) create mode 100644 example/hex/.gitignore create mode 100644 example/hex/Makefile create mode 100644 example/hex/biz/dal/init.go create mode 100644 example/hex/biz/dal/mysql/init.go create mode 100644 example/hex/biz/dal/redis/init.go create mode 100644 example/hex/biz/handler/hello/example/hello_service.go create mode 100644 example/hex/biz/router/hello/example/hello.go create mode 100644 example/hex/biz/router/hello/example/middleware.go create mode 100644 example/hex/biz/router/register.go create mode 100644 example/hex/biz/service/hello_method.go create mode 100644 example/hex/biz/service/hello_method_test.go create mode 100644 example/hex/build.sh create mode 100644 example/hex/conf/conf.go create mode 100644 example/hex/conf/dev/conf.yaml create mode 100644 example/hex/conf/online/conf.yaml create mode 100644 example/hex/conf/test/conf.yaml create mode 100644 example/hex/docker-compose.yaml create mode 100644 example/hex/go.mod create mode 100644 example/hex/go.sum create mode 100644 example/hex/handler.go create mode 100644 example/hex/hex_trans_handler.go create mode 100644 example/hex/idl/hello.thrift create mode 100644 example/hex/kitex_gen/hello/example/hello.go create mode 100644 example/hex/kitex_gen/hello/example/helloservice/client.go create mode 100644 example/hex/kitex_gen/hello/example/helloservice/helloservice.go create mode 100644 example/hex/kitex_gen/hello/example/helloservice/invoker.go create mode 100644 example/hex/kitex_gen/hello/example/helloservice/server.go create mode 100644 example/hex/kitex_gen/hello/example/k-consts.go create mode 100644 example/hex/kitex_gen/hello/example/k-hello.go create mode 100644 example/hex/kitex_info.yaml create mode 100644 example/hex/main.go create mode 100644 example/hex/readme.md create mode 100644 example/hex/script/bootstrap.sh diff --git a/example/hex/.gitignore b/example/hex/.gitignore new file mode 100644 index 00000000..30e2e352 --- /dev/null +++ b/example/hex/.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 \ No newline at end of file diff --git a/example/hex/Makefile b/example/hex/Makefile new file mode 100644 index 00000000..ca7f1eae --- /dev/null +++ b/example/hex/Makefile @@ -0,0 +1,6 @@ +mod_init: + go mod init cwgo/example/hex +hex: + cwgo server --type RPC --idl idl/hello.thrift --service p.s.m -hex +mod_tidy: + go mod tidy \ No newline at end of file diff --git a/example/hex/biz/dal/init.go b/example/hex/biz/dal/init.go new file mode 100644 index 00000000..60c8f3f9 --- /dev/null +++ b/example/hex/biz/dal/init.go @@ -0,0 +1,11 @@ +package dal + +import ( + "cwgo/example/hex/biz/dal/mysql" + "cwgo/example/hex/biz/dal/redis" +) + +func Init() { + redis.Init() + mysql.Init() +} diff --git a/example/hex/biz/dal/mysql/init.go b/example/hex/biz/dal/mysql/init.go new file mode 100644 index 00000000..3877f51e --- /dev/null +++ b/example/hex/biz/dal/mysql/init.go @@ -0,0 +1,25 @@ +package mysql + +import ( + "cwgo/example/hex/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/example/hex/biz/dal/redis/init.go b/example/hex/biz/dal/redis/init.go new file mode 100644 index 00000000..14d8fc21 --- /dev/null +++ b/example/hex/biz/dal/redis/init.go @@ -0,0 +1,24 @@ +package redis + +import ( + "context" + + "cwgo/example/hex/conf" + "github.com/redis/go-redis/v9" +) + +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/example/hex/biz/handler/hello/example/hello_service.go b/example/hex/biz/handler/hello/example/hello_service.go new file mode 100644 index 00000000..8ad2332a --- /dev/null +++ b/example/hex/biz/handler/hello/example/hello_service.go @@ -0,0 +1,27 @@ +// Code generated by hertz generator. + +package example + +import ( + "context" + + example "cwgo/example/hex/kitex_gen/hello/example" + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// HelloMethod . +// @router /hello [GET] +func HelloMethod(ctx context.Context, c *app.RequestContext) { + var err error + var req example.HelloReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(example.HelloResp) + + c.JSON(consts.StatusOK, resp) +} diff --git a/example/hex/biz/router/hello/example/hello.go b/example/hex/biz/router/hello/example/hello.go new file mode 100644 index 00000000..6ca04481 --- /dev/null +++ b/example/hex/biz/router/hello/example/hello.go @@ -0,0 +1,21 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package example + +import ( + example "cwgo/example/hex/biz/handler/hello/example" + "github.com/cloudwego/hertz/pkg/app/server" +) + +/* + This file will register all the routes of the services in the master idl. + And it will update automatically when you use the "update" command for the idl. + So don't modify the contents of the file, or your code will be deleted when it is updated. +*/ + +// Register register routes based on the IDL 'api.${HTTP Method}' annotation. +func Register(r *server.Hertz) { + + root := r.Group("/", rootMw()...) + root.GET("/hello", append(_hellomethodMw(), example.HelloMethod)...) +} diff --git a/example/hex/biz/router/hello/example/middleware.go b/example/hex/biz/router/hello/example/middleware.go new file mode 100644 index 00000000..5f45c855 --- /dev/null +++ b/example/hex/biz/router/hello/example/middleware.go @@ -0,0 +1,17 @@ +// Code generated by hertz generator. + +package example + +import ( + "github.com/cloudwego/hertz/pkg/app" +) + +func rootMw() []app.HandlerFunc { + // your code... + return nil +} + +func _hellomethodMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/example/hex/biz/router/register.go b/example/hex/biz/router/register.go new file mode 100644 index 00000000..614d5bc1 --- /dev/null +++ b/example/hex/biz/router/register.go @@ -0,0 +1,14 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package router + +import ( + hello_example "cwgo/example/hex/biz/router/hello/example" + "github.com/cloudwego/hertz/pkg/app/server" +) + +// GeneratedRegister registers routers generated by IDL. +func GeneratedRegister(r *server.Hertz) { + //INSERT_POINT: DO NOT DELETE THIS LINE! + hello_example.Register(r) +} diff --git a/example/hex/biz/service/hello_method.go b/example/hex/biz/service/hello_method.go new file mode 100644 index 00000000..9bb701fa --- /dev/null +++ b/example/hex/biz/service/hello_method.go @@ -0,0 +1,20 @@ +package service + +import ( + "context" + example "cwgo/example/hex/kitex_gen/hello/example" +) + +type HelloMethodService struct { + ctx context.Context +} // NewHelloMethodService new HelloMethodService +func NewHelloMethodService(ctx context.Context) *HelloMethodService { + return &HelloMethodService{ctx: ctx} +} + +// Run create note info +func (s *HelloMethodService) Run(request *example.HelloReq) (resp *example.HelloResp, err error) { + // Finish your business logic. + + return +} diff --git a/example/hex/biz/service/hello_method_test.go b/example/hex/biz/service/hello_method_test.go new file mode 100644 index 00000000..64176a03 --- /dev/null +++ b/example/hex/biz/service/hello_method_test.go @@ -0,0 +1,24 @@ +package service + +import ( + "context" + example "cwgo/example/hex/kitex_gen/hello/example" + "testing" +) + +func TestHelloMethod_Run(t *testing.T) { + ctx := context.Background() + s := NewHelloMethodService(ctx) + // init req and assert value + + request := &example.HelloReq{} + resp, err := s.Run(request) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if resp == nil { + t.Errorf("unexpected nil response") + } + // todo: edit your unit test + +} diff --git a/example/hex/build.sh b/example/hex/build.sh new file mode 100644 index 00000000..bbd0b3e5 --- /dev/null +++ b/example/hex/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +RUN_NAME="p.s.m" + +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} \ No newline at end of file diff --git a/example/hex/conf/conf.go b/example/hex/conf/conf.go new file mode 100644 index 00000000..ffb1e15f --- /dev/null +++ b/example/hex/conf/conf.go @@ -0,0 +1,114 @@ +package conf + +import ( + "io/ioutil" + "os" + "path/filepath" + "sync" + + "gopkg.in/validator.v2" + "gopkg.in/yaml.v2" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/kr/pretty" +) + +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"` + EnablePprof bool `yaml:"enable_pprof"` + EnableGzip bool `yaml:"enable_gzip"` + EnableAccessLog bool `yaml:"enable_access_log"` + 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/example/hex/conf/dev/conf.yaml b/example/hex/conf/dev/conf.yaml new file mode 100644 index 00000000..811b9121 --- /dev/null +++ b/example/hex/conf/dev/conf.yaml @@ -0,0 +1,22 @@ +kitex: + service: "p.s.m" + 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=utf8&parseTime=True&loc=Local" +redis: + address: "127.0.0.1:6379" + username: "" + password: "" + db: 0 \ No newline at end of file diff --git a/example/hex/conf/online/conf.yaml b/example/hex/conf/online/conf.yaml new file mode 100644 index 00000000..811b9121 --- /dev/null +++ b/example/hex/conf/online/conf.yaml @@ -0,0 +1,22 @@ +kitex: + service: "p.s.m" + 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=utf8&parseTime=True&loc=Local" +redis: + address: "127.0.0.1:6379" + username: "" + password: "" + db: 0 \ No newline at end of file diff --git a/example/hex/conf/test/conf.yaml b/example/hex/conf/test/conf.yaml new file mode 100644 index 00000000..811b9121 --- /dev/null +++ b/example/hex/conf/test/conf.yaml @@ -0,0 +1,22 @@ +kitex: + service: "p.s.m" + 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=utf8&parseTime=True&loc=Local" +redis: + address: "127.0.0.1:6379" + username: "" + password: "" + db: 0 \ No newline at end of file diff --git a/example/hex/docker-compose.yaml b/example/hex/docker-compose.yaml new file mode 100644 index 00000000..f1a626f3 --- /dev/null +++ b/example/hex/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 \ No newline at end of file diff --git a/example/hex/go.mod b/example/hex/go.mod new file mode 100644 index 00000000..924e6ad1 --- /dev/null +++ b/example/hex/go.mod @@ -0,0 +1,67 @@ +module cwgo/example/hex + +go 1.19 + +replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 + +require ( + github.com/apache/thrift v0.13.0 + github.com/cloudwego/hertz v0.6.6 + github.com/cloudwego/kitex v0.6.2 + github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20230530060140-c76e27f58391 + github.com/kr/pretty v0.3.1 + github.com/redis/go-redis/v9 v9.0.5 + gopkg.in/natefinch/lumberjack.v2 v2.2.1 + gopkg.in/validator.v2 v2.0.1 + gopkg.in/yaml.v2 v2.4.0 + gorm.io/driver/mysql v1.5.1 + gorm.io/gorm v1.25.2 +) + +require ( + github.com/bytedance/go-tagexpr/v2 v2.9.2 // indirect + github.com/bytedance/gopkg v0.0.0-20230531144706-a12972768317 // indirect + github.com/bytedance/sonic v1.8.8 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/chenzhuoyu/iasm v0.0.0-20230222070914-0b1b64b0e762 // indirect + github.com/choleraehyq/pid v0.0.16 // indirect + github.com/cloudwego/configmanager v0.2.0 // indirect + github.com/cloudwego/fastpb v0.0.4 // indirect + github.com/cloudwego/frugal v0.1.6 // indirect + github.com/cloudwego/netpoll v0.4.0 // indirect + github.com/cloudwego/thriftgo v0.2.11 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 // indirect + github.com/henrylee2cn/ameda v1.4.10 // indirect + github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect + github.com/jhump/protoreflect v1.8.2 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // 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/reflect2 v1.0.2 // indirect + github.com/nyaruka/phonenumbers v1.0.55 // indirect + github.com/oleiade/lane v1.0.1 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/sirupsen/logrus v1.9.2 // indirect + github.com/tidwall/gjson v1.13.0 // 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 + go.opentelemetry.io/otel v1.16.0 // indirect + go.opentelemetry.io/otel/trace v1.16.0 // indirect + golang.org/x/arch v0.2.0 // indirect + golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect + golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.6.0 // indirect + google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect + google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/example/hex/go.sum b/example/hex/go.sum new file mode 100644 index 00000000..8c6d7099 --- /dev/null +++ b/example/hex/go.sum @@ -0,0 +1,443 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= +git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= +github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= +github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= +github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= +github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/brianvoe/gofakeit/v6 v6.16.0/go.mod h1:Ow6qC71xtwm79anlwKRlWZW6zVq9D2XHE4QSSMP/rU8= +github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= +github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= +github.com/bytedance/go-tagexpr/v2 v2.9.2 h1:QySJaAIQgOEDQBLS3x9BxOWrnhqu5sQ+f6HaZIxD39I= +github.com/bytedance/go-tagexpr/v2 v2.9.2/go.mod h1:5qsx05dYOiUXOUgnQ7w3Oz8BYs2qtM/bJokdLb79wRM= +github.com/bytedance/gopkg v0.0.0-20220413063733-65bf48ffb3a7/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.0.0-20220509134931-d1878f638986/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.0.0-20220531084716-665b4f21126f/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.0.0-20230531144706-a12972768317 h1:SReMVmTCeJ5Nf0hU8nyWu7gAaFVD8mu5yvSH/+uLT1E= +github.com/bytedance/gopkg v0.0.0-20230531144706-a12972768317/go.mod h1:FtQG3YbQG9L/91pbKSw787yBQPutC+457AvDW77fgUQ= +github.com/bytedance/mockey v1.2.0/go.mod h1:+Jm/fzWZAuhEDrPXVjDf/jLM2BlLXJkwk94zf2JZ3X4= +github.com/bytedance/mockey v1.2.1 h1:g84ngI88hz1DR4wZTL3yOuqlEcq67MretBfQUdXwrmw= +github.com/bytedance/mockey v1.2.1/go.mod h1:+Jm/fzWZAuhEDrPXVjDf/jLM2BlLXJkwk94zf2JZ3X4= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.8.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.8.8 h1:Kj4AYbZSeENfyXicsYppYKO0K2YWab+i2UTSY7Ukz9Q= +github.com/bytedance/sonic v1.8.8/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/chenzhuoyu/iasm v0.0.0-20220818063314-28c361dae733/go.mod h1:wOQ0nsbeOLa2awv8bUYFW/EHXbjQMlZ10fAlXDB2sz8= +github.com/chenzhuoyu/iasm v0.0.0-20230222070914-0b1b64b0e762 h1:4+00EOUb1t9uxAbgY8VvgfKJKDpim3co4MqsAbelIbs= +github.com/chenzhuoyu/iasm v0.0.0-20230222070914-0b1b64b0e762/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= +github.com/choleraehyq/pid v0.0.13/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= +github.com/choleraehyq/pid v0.0.15/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= +github.com/choleraehyq/pid v0.0.16 h1:1/714sMH9IBlE/aK6xM0acTagGKSzpiR0bDt7l0cG7o= +github.com/choleraehyq/pid v0.0.16/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= +github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= +github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= +github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/configmanager v0.2.0 h1:niVpVg+wQ+npNqnH3dup96SMbR02Pk+tNErubYCJqKo= +github.com/cloudwego/configmanager v0.2.0/go.mod h1:FLIQTjxsZRGjnmDhTttWQTy6f6DghPTatfBVOs2gQLk= +github.com/cloudwego/dynamicgo v0.1.0/go.mod h1:Mdsz0XGsIImi15vxhZaHZpspNChEmBMIiWkUfD6JDKg= +github.com/cloudwego/fastpb v0.0.3/go.mod h1:/V13XFTq2TUkxj2qWReV8MwfPC4NnPcy6FsrojnsSG0= +github.com/cloudwego/fastpb v0.0.4 h1:/ROVVfoFtpfc+1pkQLzGs+azjxUbSOsAqSY4tAAx4mg= +github.com/cloudwego/fastpb v0.0.4/go.mod h1:/V13XFTq2TUkxj2qWReV8MwfPC4NnPcy6FsrojnsSG0= +github.com/cloudwego/frugal v0.1.3/go.mod h1:b981ViPYdhI56aFYsoMjl9kv6yeqYSO+iEz2jrhkCgI= +github.com/cloudwego/frugal v0.1.6 h1:aXJ7W0Omion1WTCe4JHAWinQmjXDYzHt03sabu3Rabo= +github.com/cloudwego/frugal v0.1.6/go.mod h1:9ElktKsh5qd2zDBQ5ENhPSQV7F2dZ/mXlr1eaZGDBFs= +github.com/cloudwego/hertz v0.6.6 h1:FShiLl/jB/65aH6/RlwDXuBM/yTuHEz2mb8Cx1niAPU= +github.com/cloudwego/hertz v0.6.6/go.mod h1:KhztQcZtMQ46gOjZcmCy557AKD29cbumGEV0BzwevwA= +github.com/cloudwego/kitex v0.3.2/go.mod h1:/XD07VpUD9VQWmmoepASgZ6iw//vgWikVA9MpzLC5i0= +github.com/cloudwego/kitex v0.4.4/go.mod h1:3FcH5h9Qw+dhRljSzuGSpWuThttA8DvK0BsL7HUYydo= +github.com/cloudwego/kitex v0.6.2 h1:tGAUodPptJfV4cRCIj9uEkPxZ49rKj8Dclck+eiDUik= +github.com/cloudwego/kitex v0.6.2/go.mod h1:zI1GBrjT0qloTikcCfQTgxg3Ws+yQMyaChEEOcGNUvA= +github.com/cloudwego/netpoll v0.2.4/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= +github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= +github.com/cloudwego/netpoll v0.3.2/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ= +github.com/cloudwego/netpoll v0.4.0 h1:kJ2jMsT5FtlGSNtInnprJf386TFE/rGWzl8kp0wWxx4= +github.com/cloudwego/netpoll v0.4.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ= +github.com/cloudwego/thriftgo v0.1.2/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w= +github.com/cloudwego/thriftgo v0.2.4/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4= +github.com/cloudwego/thriftgo v0.2.7/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4= +github.com/cloudwego/thriftgo v0.2.11 h1:uwFyTMBwmBJKpwxRdBvn46aHEVJJSgxkHo93RN0r3fw= +github.com/cloudwego/thriftgo v0.2.11/go.mod h1:dAyXHEmKXo0LfMCrblVEY3mUZsdeuA5+i0vF5f09j7E= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +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/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= +github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks= +github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= +github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= +github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= +github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= +github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +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 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +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/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 h1:mpL/HvfIgIejhVwAfxBQkwEjlhP5o0O9RAeTAjpwzxc= +github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3/go.mod h1:gSuNB+gJaOiQKLEZ+q+PK9Mq3SOzhRcw2GsGS/FhYDk= +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/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/henrylee2cn/ameda v1.4.8/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/ameda v1.4.10 h1:JdvI2Ekq7tapdPsuhrc4CaFiqw6QXFvZIULWJgQyCAk= +github.com/henrylee2cn/ameda v1.4.10/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 h1:yE9ULgp02BhYIrO6sdV/FPe0xQM6fNHkVQW2IAymfM0= +github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8/go.mod h1:Nhe/DM3671a5udlv2AdV2ni/MZzgfv2qrPL5nIi3EGQ= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +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/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +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/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20230530060140-c76e27f58391 h1:2uhFzKxcTP1yhcJx4rCsQjsoxmqtbo9P+RaXCZTqbeI= +github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20230530060140-c76e27f58391/go.mod h1:Kf0zvMUYs1/xlqrqthhJCw4RVyWZoAsfeAWUDN6en6U= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +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/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +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/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +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/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +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/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuwcCl3yg= +github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U= +github.com/oleiade/lane v1.0.1 h1:hXofkn7GEOubzTwNpeL9MaNy8WxolCYb9cInAIeqShU= +github.com/oleiade/lane v1.0.1/go.mod h1:IyTkraa4maLfjq/GmHR+Dxb4kCMtEGeb+qmhlrQ5Mk4= +github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= +github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= +github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/redis/go-redis/v9 v9.0.5 h1:CuQcn5HIEeK7BgElubPP8CGtE0KakrnbBSTLjathl5o= +github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= +github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= +github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +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.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/thrift-iterator/go v0.0.0-20190402154806-9b5a67519118/go.mod h1:60PRwE/TCI1UqLvn8v2pwAf6+yzTPLP/Ji5xaesWDqk= +github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.13.0 h1:3TFY9yxOQShrvmjdM76K+jc66zJeT6D3/VFFYCGQf7M= +github.com/tidwall/gjson v1.13.0/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/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631/go.mod h1:3gacX+hQo+xvl0vtLqCMufzxuNCwt4geAVOMt2LQYfE= +github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6/go.mod h1:0VP5W9AFNVWU8C1QLNeVg8TvzoEkIHWZ4vxtxEVFWUY= +github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2/go.mod h1:wen8nMxrRrUmXnRwH+3wGAW+hyYTHcOrTNhMpxyp/i0= +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.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= +go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 h1:+XWJd3jf75RXJq29mxbuXhCXFDG3S3R4vBUeSI2P7tE= +go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= +go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= +go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= +go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= +golang.org/x/arch v0.0.0-20201008161808-52c3e6f60cff/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.0.0-20220722155209-00200b7164a7/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-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= +golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +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/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +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.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +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 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/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-20210304124612-50617c2ba197/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-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/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-20220715151400-c0bba94af5f8/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.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +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-20190206041539-40960b6deb8e/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-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +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-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +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/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= +gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= +gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY= +gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= +gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= +gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= +gonum.org/v1/plot v0.10.1/go.mod h1:VZW5OlhkL1mysU9vaqNHnsy86inf6Ot+jB3r+BczCEo= +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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/validator.v2 v2.0.1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY= +gopkg.in/validator.v2 v2.0.1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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= +gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw= +gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o= +gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho= +gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +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= +honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= +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/example/hex/handler.go b/example/hex/handler.go new file mode 100644 index 00000000..74d43151 --- /dev/null +++ b/example/hex/handler.go @@ -0,0 +1,17 @@ +package main + +import ( + "context" + "cwgo/example/hex/biz/service" + example "cwgo/example/hex/kitex_gen/hello/example" +) + +// HelloServiceImpl implements the last service interface defined in the IDL. +type HelloServiceImpl struct{} + +// HelloMethod implements the HelloServiceImpl interface. +func (s *HelloServiceImpl) HelloMethod(ctx context.Context, request *example.HelloReq) (resp *example.HelloResp, err error) { + resp, err = service.NewHelloMethodService(ctx).Run(request) + + return resp, err +} diff --git a/example/hex/hex_trans_handler.go b/example/hex/hex_trans_handler.go new file mode 100644 index 00000000..4e3045b8 --- /dev/null +++ b/example/hex/hex_trans_handler.go @@ -0,0 +1,93 @@ +package main + +import ( + "context" + "errors" + "fmt" + "net" + "regexp" + + "github.com/cloudwego/hertz/pkg/app" + hertzServer "github.com/cloudwego/hertz/pkg/app/server" + "github.com/cloudwego/hertz/pkg/common/utils" + "github.com/cloudwego/hertz/pkg/network" + "github.com/cloudwego/hertz/pkg/protocol/consts" + "github.com/cloudwego/hertz/pkg/route" + "github.com/cloudwego/kitex/pkg/endpoint" + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/remote" + "github.com/cloudwego/kitex/pkg/remote/trans/detection" + "github.com/cloudwego/kitex/pkg/remote/trans/netpoll" + "github.com/cloudwego/kitex/pkg/remote/trans/nphttp2" + "cwgo/example/hex/biz/router" +) + +type mixTransHandlerFactory struct { + originFactory remote.ServerTransHandlerFactory +} + +type transHandler struct { + remote.ServerTransHandler +} + +// SetInvokeHandleFunc is used to set invoke handle func. +func (t *transHandler) SetInvokeHandleFunc(inkHdlFunc endpoint.Endpoint) { + t.ServerTransHandler.(remote.InvokeHandleFuncSetter).SetInvokeHandleFunc(inkHdlFunc) +} + +func (m mixTransHandlerFactory) NewTransHandler(opt *remote.ServerOption) (remote.ServerTransHandler, error) { + var kitexOrigin remote.ServerTransHandler + var err error + + if m.originFactory != nil { + kitexOrigin, err = m.originFactory.NewTransHandler(opt) + } else { + // if no customized factory just use the default factory under detection pkg. + kitexOrigin, err = detection.NewSvrTransHandlerFactory(netpoll.NewSvrTransHandlerFactory(), nphttp2.NewSvrTransHandlerFactory()).NewTransHandler(opt) + } + if err != nil { + return nil, err + } + return &transHandler{ServerTransHandler: kitexOrigin}, nil +} + +var httpReg = regexp.MustCompile(`^(?:GET |POST|PUT|DELE|HEAD|OPTI|CONN|TRAC|PATC)$`) + +func (t *transHandler) OnRead(ctx context.Context, conn net.Conn) error { + c, ok := conn.(network.Conn) + if ok { + pre, _ := c.Peek(4) + if httpReg.Match(pre) { + klog.Info("using Hertz to process request") + err := hertzEngine.Serve(ctx, c) + if err != nil { + err = errors.New(fmt.Sprintf("HERTZ: %s", err.Error())) + } + return err + } + } + return t.ServerTransHandler.OnRead(ctx, conn) +} + +func initHertz() *route.Engine { + h := hertzServer.New() + + // add a ping route to test + h.GET("/ping", func(c context.Context, ctx *app.RequestContext) { + ctx.JSON(consts.StatusOK, utils.H{"ping": "pong"}) + }) + + router.GeneratedRegister(h) + err := h.Engine.Init() + if err != nil { + panic(err) + } + return h.Engine +} + +var hertzEngine *route.Engine + +func init() { + hertzEngine = initHertz() +} + diff --git a/example/hex/idl/hello.thrift b/example/hex/idl/hello.thrift new file mode 100644 index 00000000..b6d3457e --- /dev/null +++ b/example/hex/idl/hello.thrift @@ -0,0 +1,15 @@ +// idl/hello.thrift +namespace go hello.example + +struct HelloReq { + 1: string Name (api.query="name"); // 对应HTTP query参数 +} + +struct HelloResp { + 1: string RespBody; +} + + +service HelloService { + HelloResp HelloMethod(1: HelloReq request) (api.get="/hello"); // 对应HTTP路由url +} \ No newline at end of file diff --git a/example/hex/kitex_gen/hello/example/hello.go b/example/hex/kitex_gen/hello/example/hello.go new file mode 100644 index 00000000..e516e3f8 --- /dev/null +++ b/example/hex/kitex_gen/hello/example/hello.go @@ -0,0 +1,814 @@ +// Code generated by thriftgo (0.2.12). DO NOT EDIT. + +package example + +import ( + "context" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "strings" +) + +type HelloReq struct { + // 对应HTTP query参数 + Name string `thrift:"Name,1" frugal:"1,default,string" json:"Name" query:"name"` +} + +func NewHelloReq() *HelloReq { + return &HelloReq{} +} + +func (p *HelloReq) InitDefault() { + *p = HelloReq{} +} + +func (p *HelloReq) GetName() (v string) { + return p.Name +} +func (p *HelloReq) SetName(val string) { + p.Name = val +} + +var fieldIDToName_HelloReq = map[int16]string{ + 1: "Name", +} + +func (p *HelloReq) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloReq[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloReq) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Name = v + } + return nil +} + +func (p *HelloReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloReq"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloReq) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Name", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Name); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *HelloReq) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloReq(%+v)", *p) +} + +func (p *HelloReq) DeepEqual(ano *HelloReq) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Name) { + return false + } + return true +} + +func (p *HelloReq) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Name, src) != 0 { + return false + } + return true +} + +type HelloResp struct { + RespBody string `thrift:"RespBody,1" frugal:"1,default,string" form:"RespBody" json:"RespBody" query:"RespBody"` +} + +func NewHelloResp() *HelloResp { + return &HelloResp{} +} + +func (p *HelloResp) InitDefault() { + *p = HelloResp{} +} + +func (p *HelloResp) GetRespBody() (v string) { + return p.RespBody +} +func (p *HelloResp) SetRespBody(val string) { + p.RespBody = val +} + +var fieldIDToName_HelloResp = map[int16]string{ + 1: "RespBody", +} + +func (p *HelloResp) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloResp[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloResp) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.RespBody = v + } + return nil +} + +func (p *HelloResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloResp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloResp) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("RespBody", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.RespBody); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *HelloResp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloResp(%+v)", *p) +} + +func (p *HelloResp) DeepEqual(ano *HelloResp) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.RespBody) { + return false + } + return true +} + +func (p *HelloResp) Field1DeepEqual(src string) bool { + + if strings.Compare(p.RespBody, src) != 0 { + return false + } + return true +} + +type HelloService interface { + HelloMethod(ctx context.Context, request *HelloReq) (r *HelloResp, err error) +} + +type HelloServiceClient struct { + c thrift.TClient +} + +func NewHelloServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *HelloServiceClient { + return &HelloServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewHelloServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *HelloServiceClient { + return &HelloServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewHelloServiceClient(c thrift.TClient) *HelloServiceClient { + return &HelloServiceClient{ + c: c, + } +} + +func (p *HelloServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *HelloServiceClient) HelloMethod(ctx context.Context, request *HelloReq) (r *HelloResp, err error) { + var _args HelloServiceHelloMethodArgs + _args.Request = request + var _result HelloServiceHelloMethodResult + if err = p.Client_().Call(ctx, "HelloMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type HelloServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler HelloService +} + +func (p *HelloServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *HelloServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *HelloServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewHelloServiceProcessor(handler HelloService) *HelloServiceProcessor { + self := &HelloServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("HelloMethod", &helloServiceProcessorHelloMethod{handler: handler}) + return self +} +func (p *HelloServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type helloServiceProcessorHelloMethod struct { + handler HelloService +} + +func (p *helloServiceProcessorHelloMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := HelloServiceHelloMethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("HelloMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := HelloServiceHelloMethodResult{} + var retval *HelloResp + if retval, err2 = p.handler.HelloMethod(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing HelloMethod: "+err2.Error()) + oprot.WriteMessageBegin("HelloMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("HelloMethod", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type HelloServiceHelloMethodArgs struct { + Request *HelloReq `thrift:"request,1" frugal:"1,default,HelloReq"` +} + +func NewHelloServiceHelloMethodArgs() *HelloServiceHelloMethodArgs { + return &HelloServiceHelloMethodArgs{} +} + +func (p *HelloServiceHelloMethodArgs) InitDefault() { + *p = HelloServiceHelloMethodArgs{} +} + +var HelloServiceHelloMethodArgs_Request_DEFAULT *HelloReq + +func (p *HelloServiceHelloMethodArgs) GetRequest() (v *HelloReq) { + if !p.IsSetRequest() { + return HelloServiceHelloMethodArgs_Request_DEFAULT + } + return p.Request +} +func (p *HelloServiceHelloMethodArgs) SetRequest(val *HelloReq) { + p.Request = val +} + +var fieldIDToName_HelloServiceHelloMethodArgs = map[int16]string{ + 1: "request", +} + +func (p *HelloServiceHelloMethodArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *HelloServiceHelloMethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) ReadField1(iprot thrift.TProtocol) error { + p.Request = NewHelloReq() + if err := p.Request.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *HelloServiceHelloMethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloMethod_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloServiceHelloMethodArgs(%+v)", *p) +} + +func (p *HelloServiceHelloMethodArgs) DeepEqual(ano *HelloServiceHelloMethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Request) { + return false + } + return true +} + +func (p *HelloServiceHelloMethodArgs) Field1DeepEqual(src *HelloReq) bool { + + if !p.Request.DeepEqual(src) { + return false + } + return true +} + +type HelloServiceHelloMethodResult struct { + Success *HelloResp `thrift:"success,0,optional" frugal:"0,optional,HelloResp"` +} + +func NewHelloServiceHelloMethodResult() *HelloServiceHelloMethodResult { + return &HelloServiceHelloMethodResult{} +} + +func (p *HelloServiceHelloMethodResult) InitDefault() { + *p = HelloServiceHelloMethodResult{} +} + +var HelloServiceHelloMethodResult_Success_DEFAULT *HelloResp + +func (p *HelloServiceHelloMethodResult) GetSuccess() (v *HelloResp) { + if !p.IsSetSuccess() { + return HelloServiceHelloMethodResult_Success_DEFAULT + } + return p.Success +} +func (p *HelloServiceHelloMethodResult) SetSuccess(x interface{}) { + p.Success = x.(*HelloResp) +} + +var fieldIDToName_HelloServiceHelloMethodResult = map[int16]string{ + 0: "success", +} + +func (p *HelloServiceHelloMethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *HelloServiceHelloMethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewHelloResp() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *HelloServiceHelloMethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloMethod_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloServiceHelloMethodResult(%+v)", *p) +} + +func (p *HelloServiceHelloMethodResult) DeepEqual(ano *HelloServiceHelloMethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *HelloServiceHelloMethodResult) Field0DeepEqual(src *HelloResp) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/example/hex/kitex_gen/hello/example/helloservice/client.go b/example/hex/kitex_gen/hello/example/helloservice/client.go new file mode 100644 index 00000000..254a30d3 --- /dev/null +++ b/example/hex/kitex_gen/hello/example/helloservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.6.1. DO NOT EDIT. + +package helloservice + +import ( + "context" + example "cwgo/example/hex/kitex_gen/hello/example" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + HelloMethod(ctx context.Context, request *example.HelloReq, callOptions ...callopt.Option) (r *example.HelloResp, 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 &kHelloServiceClient{ + 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 kHelloServiceClient struct { + *kClient +} + +func (p *kHelloServiceClient) HelloMethod(ctx context.Context, request *example.HelloReq, callOptions ...callopt.Option) (r *example.HelloResp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.HelloMethod(ctx, request) +} diff --git a/example/hex/kitex_gen/hello/example/helloservice/helloservice.go b/example/hex/kitex_gen/hello/example/helloservice/helloservice.go new file mode 100644 index 00000000..38ccc3e2 --- /dev/null +++ b/example/hex/kitex_gen/hello/example/helloservice/helloservice.go @@ -0,0 +1,74 @@ +// Code generated by Kitex v0.6.1. DO NOT EDIT. + +package helloservice + +import ( + "context" + example "cwgo/example/hex/kitex_gen/hello/example" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return helloServiceServiceInfo +} + +var helloServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "HelloService" + handlerType := (*example.HelloService)(nil) + methods := map[string]kitex.MethodInfo{ + "HelloMethod": kitex.NewMethodInfo(helloMethodHandler, newHelloServiceHelloMethodArgs, newHelloServiceHelloMethodResult, false), + } + extra := map[string]interface{}{ + "PackageName": "example", + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.6.1", + Extra: extra, + } + return svcInfo +} + +func helloMethodHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*example.HelloServiceHelloMethodArgs) + realResult := result.(*example.HelloServiceHelloMethodResult) + success, err := handler.(example.HelloService).HelloMethod(ctx, realArg.Request) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newHelloServiceHelloMethodArgs() interface{} { + return example.NewHelloServiceHelloMethodArgs() +} + +func newHelloServiceHelloMethodResult() interface{} { + return example.NewHelloServiceHelloMethodResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) HelloMethod(ctx context.Context, request *example.HelloReq) (r *example.HelloResp, err error) { + var _args example.HelloServiceHelloMethodArgs + _args.Request = request + var _result example.HelloServiceHelloMethodResult + if err = p.c.Call(ctx, "HelloMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/example/hex/kitex_gen/hello/example/helloservice/invoker.go b/example/hex/kitex_gen/hello/example/helloservice/invoker.go new file mode 100644 index 00000000..0ee6afe9 --- /dev/null +++ b/example/hex/kitex_gen/hello/example/helloservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.6.1. DO NOT EDIT. + +package helloservice + +import ( + example "cwgo/example/hex/kitex_gen/hello/example" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler example.HelloService, 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/example/hex/kitex_gen/hello/example/helloservice/server.go b/example/hex/kitex_gen/hello/example/helloservice/server.go new file mode 100644 index 00000000..ec93bbe6 --- /dev/null +++ b/example/hex/kitex_gen/hello/example/helloservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.6.1. DO NOT EDIT. +package helloservice + +import ( + example "cwgo/example/hex/kitex_gen/hello/example" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler example.HelloService, 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 +} diff --git a/example/hex/kitex_gen/hello/example/k-consts.go b/example/hex/kitex_gen/hello/example/k-consts.go new file mode 100644 index 00000000..06e77a2b --- /dev/null +++ b/example/hex/kitex_gen/hello/example/k-consts.go @@ -0,0 +1,4 @@ +package example + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/example/hex/kitex_gen/hello/example/k-hello.go b/example/hex/kitex_gen/hello/example/k-hello.go new file mode 100644 index 00000000..d0e683e0 --- /dev/null +++ b/example/hex/kitex_gen/hello/example/k-hello.go @@ -0,0 +1,550 @@ +// Code generated by Kitex v0.6.1. DO NOT EDIT. + +package example + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *HelloReq) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloReq[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloReq) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Name = v + + } + return offset, nil +} + +// for compatibility +func (p *HelloReq) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloReq") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloReq) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloReq") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Name", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *HelloReq) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Name", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Name) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *HelloResp) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloResp[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloResp) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.RespBody = v + + } + return offset, nil +} + +// for compatibility +func (p *HelloResp) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloResp") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloResp) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloResp") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "RespBody", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RespBody) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *HelloResp) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("RespBody", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.RespBody) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *HelloServiceHelloMethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewHelloReq() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Request = tmp + return offset, nil +} + +// for compatibility +func (p *HelloServiceHelloMethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloServiceHelloMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloMethod_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloServiceHelloMethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloMethod_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloServiceHelloMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "request", thrift.STRUCT, 1) + offset += p.Request.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *HelloServiceHelloMethodArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("request", thrift.STRUCT, 1) + l += p.Request.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *HelloServiceHelloMethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewHelloResp() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *HelloServiceHelloMethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloServiceHelloMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloMethod_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloServiceHelloMethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloMethod_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloServiceHelloMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *HelloServiceHelloMethodResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *HelloServiceHelloMethodArgs) GetFirstArgument() interface{} { + return p.Request +} + +func (p *HelloServiceHelloMethodResult) GetResult() interface{} { + return p.Success +} diff --git a/example/hex/kitex_info.yaml b/example/hex/kitex_info.yaml new file mode 100644 index 00000000..0a472f77 --- /dev/null +++ b/example/hex/kitex_info.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'p.s.m' + ToolVersion: 'v0.6.1' \ No newline at end of file diff --git a/example/hex/main.go b/example/hex/main.go new file mode 100644 index 00000000..5f13b483 --- /dev/null +++ b/example/hex/main.go @@ -0,0 +1,56 @@ +package main + +import ( + "net" + + "cwgo/example/hex/conf" + "cwgo/example/hex/kitex_gen/hello/example/helloservice" + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/pkg/transmeta" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "gopkg.in/natefinch/lumberjack.v2" +) + +func main() { + opts := kitexInit() + + svr := helloservice.NewServer(new(HelloServiceImpl), opts...) + + err := svr.Run() + if err != nil { + klog.Error(err.Error()) + } +} + +func kitexInit() (opts []server.Option) { + opts = append(opts, server. + WithTransHandlerFactory(&mixTransHandlerFactory{nil})) + + // 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, + })) + // thrift meta handler + opts = append(opts, server.WithMetaHandler(transmeta.ServerTTHeaderHandler)) + + // klog + logger := kitexlogrus.NewLogger() + klog.SetLogger(logger) + klog.SetLevel(conf.LogLevel()) + klog.SetOutput(&lumberjack.Logger{ + Filename: conf.GetConf().Kitex.LogFileName, + MaxSize: conf.GetConf().Kitex.LogMaxSize, + MaxBackups: conf.GetConf().Kitex.LogMaxBackups, + MaxAge: conf.GetConf().Kitex.LogMaxAge, + }) + return +} diff --git a/example/hex/readme.md b/example/hex/readme.md new file mode 100644 index 00000000..a1b26eb1 --- /dev/null +++ b/example/hex/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 +``` \ No newline at end of file diff --git a/example/hex/script/bootstrap.sh b/example/hex/script/bootstrap.sh new file mode 100644 index 00000000..e136af11 --- /dev/null +++ b/example/hex/script/bootstrap.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) +echo "$CURDIR/bin/p.s.m" +exec "$CURDIR/bin/p.s.m" \ No newline at end of file From 3b9f22cc005e2f0e474df7a2265b862cc4037d73 Mon Sep 17 00:00:00 2001 From: fgy Date: Fri, 4 Aug 2023 11:34:10 +0800 Subject: [PATCH 3/8] feat: file exist --- pkg/server/kitex.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/server/kitex.go b/pkg/server/kitex.go index a7a4571b..fd7245a1 100644 --- a/pkg/server/kitex.go +++ b/pkg/server/kitex.go @@ -321,18 +321,18 @@ func (t *transHandler) OnRead(ctx context.Context, conn net.Conn) error { } func initHertz() *route.Engine { - h := hertzServer.New() - + h := hertzServer.New(hertzServer.WithIdleTimeout(0)) // add a ping route to test h.GET("/ping", func(c context.Context, ctx *app.RequestContext) { ctx.JSON(consts.StatusOK, utils.H{"ping": "pong"}) }) - router.GeneratedRegister(h) - err := h.Engine.Init() - if err != nil { + if err := h.Engine.Init(); err != nil { panic(err) } + //if err := h.Engine.SetEngineRun(); err != nil { + // panic(err) + //} return h.Engine } @@ -343,6 +343,9 @@ func init() { } ` + if util.Exists("hex_trans_handler.go") { + return nil + } tmpl := template.Must(template.New("hex_trans_handler").Parse(tmplContent)) file, err := os.Create("hex_trans_handler.go") if err != nil { From 2e913acfc11a13114ea9eb41a8fb268a29baef87 Mon Sep 17 00:00:00 2001 From: fgy Date: Fri, 4 Aug 2023 11:36:44 +0800 Subject: [PATCH 4/8] feat: unify first letter --- cmd/static/server_flags.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/static/server_flags.go b/cmd/static/server_flags.go index 1cd2c3ca..372cb523 100644 --- a/cmd/static/server_flags.go +++ b/cmd/static/server_flags.go @@ -28,11 +28,11 @@ func serverFlags() []cli.Flag { &cli.StringFlag{Name: config.ServiceType, Usage: "Specify the generate type. (RPC or HTTP)", Value: config.RPC}, &cli.StringFlag{Name: config.Module, Aliases: []string{"mod"}, Usage: "Specify the Go module name to generate go.mod.", Destination: &globalArgs.ServerArgument.GoMod}, &cli.StringFlag{Name: config.IDLPath, Usage: "Specify the IDL file path. (.thrift or .proto)", Destination: &globalArgs.ServerArgument.IdlPath}, - &cli.StringFlag{Name: config.OutDir, Value: ".", Aliases: []string{"o"}, Usage: "Specify the output path. Currently cwgo supports git templates, such as `--template https://github.com/***/cwgo_template.git`", Destination: &globalArgs.ServerArgument.OutDir}, + &cli.StringFlag{Name: config.OutDir, Value: ".", Aliases: []string{"o"}, Usage: "Specify the output path. Currently cwgo supports git templates, such as `--template https://github.com/***/cwgo_template.git`.", Destination: &globalArgs.ServerArgument.OutDir}, &cli.StringFlag{Name: config.Template, Usage: "Specify the layout template.", Destination: &globalArgs.ServerArgument.Template}, - &cli.StringFlag{Name: config.Registry, Usage: "Specify the registry, default is None"}, - &cli.StringSliceFlag{Name: config.ProtoSearchPath, Aliases: []string{"I"}, Usage: "Add an IDL search path for includes. (Valid only if idl is protobuf)"}, - &cli.StringSliceFlag{Name: config.Pass, Usage: "pass param to hz or kitex"}, + &cli.StringFlag{Name: config.Registry, Usage: "Specify the registry, default is None."}, + &cli.StringSliceFlag{Name: config.ProtoSearchPath, Aliases: []string{"I"}, Usage: "Add an IDL search path for includes."}, + &cli.StringSliceFlag{Name: config.Pass, Usage: "Pass param to hz or Kitex."}, &cli.BoolFlag{Name: config.Verbose, Usage: "Turn on verbose mode."}, &cli.BoolFlag{Name: config.HexTag, Usage: "Add HTTP listen for Kitex.", Destination: &globalArgs.Hex}, } From f283c4c0800c1a1c23be96d286d0dd3e6f8fc496 Mon Sep 17 00:00:00 2001 From: fgy Date: Fri, 4 Aug 2023 11:39:46 +0800 Subject: [PATCH 5/8] feat: format --- example/hex/Makefile | 2 +- example/hex/readme.md | 26 -------------------------- 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 example/hex/readme.md diff --git a/example/hex/Makefile b/example/hex/Makefile index ca7f1eae..dbb103ad 100644 --- a/example/hex/Makefile +++ b/example/hex/Makefile @@ -1,6 +1,6 @@ mod_init: go mod init cwgo/example/hex hex: - cwgo server --type RPC --idl idl/hello.thrift --service p.s.m -hex + cwgo server --type RPC --idl idl/hello.thrift --service p.s.m --hex mod_tidy: go mod tidy \ No newline at end of file diff --git a/example/hex/readme.md b/example/hex/readme.md deleted file mode 100644 index a1b26eb1..00000000 --- a/example/hex/readme.md +++ /dev/null @@ -1,26 +0,0 @@ -# *** 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 -``` \ No newline at end of file From 4f7ccd0de43577504efcd928525e0c299382a7dc Mon Sep 17 00:00:00 2001 From: fgy Date: Fri, 4 Aug 2023 14:41:58 +0800 Subject: [PATCH 6/8] feat: add license --- _typos.toml | 5 +++++ example/hex/biz/dal/init.go | 16 ++++++++++++++++ example/hex/biz/dal/mysql/init.go | 16 ++++++++++++++++ example/hex/biz/dal/redis/init.go | 16 ++++++++++++++++ .../biz/handler/hello/example/hello_service.go | 16 ++++++++++++++++ example/hex/biz/router/hello/example/hello.go | 16 ++++++++++++++++ .../hex/biz/router/hello/example/middleware.go | 16 ++++++++++++++++ example/hex/biz/router/register.go | 16 ++++++++++++++++ example/hex/biz/service/hello_method.go | 16 ++++++++++++++++ example/hex/biz/service/hello_method_test.go | 16 ++++++++++++++++ example/hex/conf/conf.go | 16 ++++++++++++++++ example/hex/handler.go | 16 ++++++++++++++++ example/hex/hex_trans_handler.go | 16 ++++++++++++++++ example/hex/kitex_gen/hello/example/hello.go | 16 ++++++++++++++++ .../hello/example/helloservice/client.go | 16 ++++++++++++++++ .../hello/example/helloservice/helloservice.go | 16 ++++++++++++++++ .../hello/example/helloservice/invoker.go | 16 ++++++++++++++++ .../hello/example/helloservice/server.go | 16 ++++++++++++++++ example/hex/kitex_gen/hello/example/k-consts.go | 16 ++++++++++++++++ example/hex/kitex_gen/hello/example/k-hello.go | 16 ++++++++++++++++ example/hex/main.go | 16 ++++++++++++++++ 21 files changed, 325 insertions(+) diff --git a/_typos.toml b/_typos.toml index 01fa9e62..dd7253ad 100644 --- a/_typos.toml +++ b/_typos.toml @@ -2,3 +2,8 @@ [files] extend-exclude = ["go.sum", "check_branch_name.sh"] + +[default.extend-identifiers] +# *sigh* this just isn't worth the cost of fixing +O_WRONLY = "O_WRONLY" +WRONLY = "WRONLY" \ No newline at end of file diff --git a/example/hex/biz/dal/init.go b/example/hex/biz/dal/init.go index 60c8f3f9..989f09c3 100644 --- a/example/hex/biz/dal/init.go +++ b/example/hex/biz/dal/init.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package dal import ( diff --git a/example/hex/biz/dal/mysql/init.go b/example/hex/biz/dal/mysql/init.go index 3877f51e..6dc6e83f 100644 --- a/example/hex/biz/dal/mysql/init.go +++ b/example/hex/biz/dal/mysql/init.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package mysql import ( diff --git a/example/hex/biz/dal/redis/init.go b/example/hex/biz/dal/redis/init.go index 14d8fc21..cce6bc7c 100644 --- a/example/hex/biz/dal/redis/init.go +++ b/example/hex/biz/dal/redis/init.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package redis import ( diff --git a/example/hex/biz/handler/hello/example/hello_service.go b/example/hex/biz/handler/hello/example/hello_service.go index 8ad2332a..1ddf5a1d 100644 --- a/example/hex/biz/handler/hello/example/hello_service.go +++ b/example/hex/biz/handler/hello/example/hello_service.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by hertz generator. package example diff --git a/example/hex/biz/router/hello/example/hello.go b/example/hex/biz/router/hello/example/hello.go index 6ca04481..09878756 100644 --- a/example/hex/biz/router/hello/example/hello.go +++ b/example/hex/biz/router/hello/example/hello.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by hertz generator. DO NOT EDIT. package example diff --git a/example/hex/biz/router/hello/example/middleware.go b/example/hex/biz/router/hello/example/middleware.go index 5f45c855..1c21f5a8 100644 --- a/example/hex/biz/router/hello/example/middleware.go +++ b/example/hex/biz/router/hello/example/middleware.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by hertz generator. package example diff --git a/example/hex/biz/router/register.go b/example/hex/biz/router/register.go index 614d5bc1..1afb929e 100644 --- a/example/hex/biz/router/register.go +++ b/example/hex/biz/router/register.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by hertz generator. DO NOT EDIT. package router diff --git a/example/hex/biz/service/hello_method.go b/example/hex/biz/service/hello_method.go index 9bb701fa..a6cc08f9 100644 --- a/example/hex/biz/service/hello_method.go +++ b/example/hex/biz/service/hello_method.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package service import ( diff --git a/example/hex/biz/service/hello_method_test.go b/example/hex/biz/service/hello_method_test.go index 64176a03..c5a23494 100644 --- a/example/hex/biz/service/hello_method_test.go +++ b/example/hex/biz/service/hello_method_test.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package service import ( diff --git a/example/hex/conf/conf.go b/example/hex/conf/conf.go index ffb1e15f..1e472560 100644 --- a/example/hex/conf/conf.go +++ b/example/hex/conf/conf.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package conf import ( diff --git a/example/hex/handler.go b/example/hex/handler.go index 74d43151..7241efeb 100644 --- a/example/hex/handler.go +++ b/example/hex/handler.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( diff --git a/example/hex/hex_trans_handler.go b/example/hex/hex_trans_handler.go index 4e3045b8..1debb774 100644 --- a/example/hex/hex_trans_handler.go +++ b/example/hex/hex_trans_handler.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( diff --git a/example/hex/kitex_gen/hello/example/hello.go b/example/hex/kitex_gen/hello/example/hello.go index e516e3f8..55e2b006 100644 --- a/example/hex/kitex_gen/hello/example/hello.go +++ b/example/hex/kitex_gen/hello/example/hello.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by thriftgo (0.2.12). DO NOT EDIT. package example diff --git a/example/hex/kitex_gen/hello/example/helloservice/client.go b/example/hex/kitex_gen/hello/example/helloservice/client.go index 254a30d3..143da695 100644 --- a/example/hex/kitex_gen/hello/example/helloservice/client.go +++ b/example/hex/kitex_gen/hello/example/helloservice/client.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by Kitex v0.6.1. DO NOT EDIT. package helloservice diff --git a/example/hex/kitex_gen/hello/example/helloservice/helloservice.go b/example/hex/kitex_gen/hello/example/helloservice/helloservice.go index 38ccc3e2..0a4ff7c5 100644 --- a/example/hex/kitex_gen/hello/example/helloservice/helloservice.go +++ b/example/hex/kitex_gen/hello/example/helloservice/helloservice.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by Kitex v0.6.1. DO NOT EDIT. package helloservice diff --git a/example/hex/kitex_gen/hello/example/helloservice/invoker.go b/example/hex/kitex_gen/hello/example/helloservice/invoker.go index 0ee6afe9..f74aadb7 100644 --- a/example/hex/kitex_gen/hello/example/helloservice/invoker.go +++ b/example/hex/kitex_gen/hello/example/helloservice/invoker.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by Kitex v0.6.1. DO NOT EDIT. package helloservice diff --git a/example/hex/kitex_gen/hello/example/helloservice/server.go b/example/hex/kitex_gen/hello/example/helloservice/server.go index ec93bbe6..e19fd7ab 100644 --- a/example/hex/kitex_gen/hello/example/helloservice/server.go +++ b/example/hex/kitex_gen/hello/example/helloservice/server.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by Kitex v0.6.1. DO NOT EDIT. package helloservice diff --git a/example/hex/kitex_gen/hello/example/k-consts.go b/example/hex/kitex_gen/hello/example/k-consts.go index 06e77a2b..cdb1d745 100644 --- a/example/hex/kitex_gen/hello/example/k-consts.go +++ b/example/hex/kitex_gen/hello/example/k-consts.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package example // KitexUnusedProtection is used to prevent 'imported and not used' error. diff --git a/example/hex/kitex_gen/hello/example/k-hello.go b/example/hex/kitex_gen/hello/example/k-hello.go index d0e683e0..a5d66bbb 100644 --- a/example/hex/kitex_gen/hello/example/k-hello.go +++ b/example/hex/kitex_gen/hello/example/k-hello.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by Kitex v0.6.1. DO NOT EDIT. package example diff --git a/example/hex/main.go b/example/hex/main.go index 5f13b483..44d087af 100644 --- a/example/hex/main.go +++ b/example/hex/main.go @@ -1,3 +1,19 @@ +/* + * Copyright 2023 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( From 258ca6f1e3158ead85f39342187b5bab7a8ff344 Mon Sep 17 00:00:00 2001 From: fgy Date: Fri, 4 Aug 2023 14:46:34 +0800 Subject: [PATCH 7/8] feat: ignore license --- .licenserc.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.licenserc.yaml b/.licenserc.yaml index 6046e128..93924370 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -7,4 +7,7 @@ header: - '**/*.go' - '**/*.s' + paths-ignore: + - "example/**" + comment: on-failure \ No newline at end of file From cc7f2704386a4e2490a1627d6e7cfe652ba7431e Mon Sep 17 00:00:00 2001 From: fgy Date: Wed, 23 Aug 2023 14:54:31 +0800 Subject: [PATCH 8/8] feat: add test code --- example/hex/README.md | 24 +++++++++++++++++++ .../handler/hello/example/hello_service.go | 2 ++ example/hex/biz/service/hello_method.go | 6 ++++- example/hex/client/main.go | 23 ++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 example/hex/README.md create mode 100644 example/hex/client/main.go diff --git a/example/hex/README.md b/example/hex/README.md new file mode 100644 index 00000000..82b83824 --- /dev/null +++ b/example/hex/README.md @@ -0,0 +1,24 @@ +# CWGO Hex Usage + +## Introduce +The main power of `cwgo hex` is to allow hertz and kitex to listen on the same port and use protocol sniffing to distribute requests to kitex and hertz for processing +## Install +``` +# Go 1.15 and earlier version +GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get github.com/cloudwego/cwgo@latest + +# Go 1.16 and later version +GOPROXY=https://goproxy.cn/,direct go install github.com/cloudwego/cwgo@latest +``` +## Usage +- init go.mod `go mod init cwgo/example/hex` +- generate code `cwgo server --type RPC --idl idl/hello.thrift --service p.s.m --hex` +- mod tidy `go mod tidy` + +## Test +- `cd /cwgo/example/hex` +- start server: `go run .` +- test rpc: `go run client/main.go` + - `HelloResp({RespBody:[KITEX] hello, hex})` +- test http: `curl 127.0.0.1:8888/hello?name=hex` + - `{"RespBody":"[HERTZ] hello, hex"}` \ No newline at end of file diff --git a/example/hex/biz/handler/hello/example/hello_service.go b/example/hex/biz/handler/hello/example/hello_service.go index 1ddf5a1d..d536e756 100644 --- a/example/hex/biz/handler/hello/example/hello_service.go +++ b/example/hex/biz/handler/hello/example/hello_service.go @@ -20,6 +20,7 @@ package example import ( "context" + "fmt" example "cwgo/example/hex/kitex_gen/hello/example" "github.com/cloudwego/hertz/pkg/app" @@ -38,6 +39,7 @@ func HelloMethod(ctx context.Context, c *app.RequestContext) { } resp := new(example.HelloResp) + resp.RespBody = fmt.Sprintf("[HERTZ] hello, %s", req.Name) c.JSON(consts.StatusOK, resp) } diff --git a/example/hex/biz/service/hello_method.go b/example/hex/biz/service/hello_method.go index a6cc08f9..9ca7bae9 100644 --- a/example/hex/biz/service/hello_method.go +++ b/example/hex/biz/service/hello_method.go @@ -19,6 +19,8 @@ package service import ( "context" example "cwgo/example/hex/kitex_gen/hello/example" + "fmt" + "github.com/cloudwego/kitex/pkg/klog" ) type HelloMethodService struct { @@ -31,6 +33,8 @@ func NewHelloMethodService(ctx context.Context) *HelloMethodService { // Run create note info func (s *HelloMethodService) Run(request *example.HelloReq) (resp *example.HelloResp, err error) { // Finish your business logic. - + resp = new(example.HelloResp) + resp.RespBody = fmt.Sprintf("[KITEX] hello, %s", request.Name) + klog.Infof("[KITEX] hello, %s", request.Name) return } diff --git a/example/hex/client/main.go b/example/hex/client/main.go new file mode 100644 index 00000000..ea4e20a4 --- /dev/null +++ b/example/hex/client/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "context" + "fmt" + + "cwgo/example/hex/kitex_gen/hello/example" + "cwgo/example/hex/kitex_gen/hello/example/helloservice" + "github.com/cloudwego/kitex/client" +) + +func main() { + kc, err := helloservice.NewClient("p.s.m", client.WithHostPorts("127.0.0.1:8888")) + if err != nil { + panic(err) + } + req := &example.HelloReq{Name: "hex"} + resp, err := kc.HelloMethod(context.Background(), req) + if err != nil { + panic(err) + } + fmt.Println(resp) +}