Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v0.9.0 #1109

Merged
merged 22 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ad3f359
refactor: client query enum
FGYFFFF Feb 6, 2024
c6927c4
chore: merge back v0.8.1 (#1068)
FGYFFFF Feb 20, 2024
9d07631
Merge branch 'develop' into refactor/client_query_enum
FGYFFFF Feb 20, 2024
1f9997c
optimize: filter shortConnErr in tracer (#1037)
li-jin-gou Mar 5, 2024
f91ce33
chore: update readme images and documentation (#1075)
GuangmingLuo Mar 7, 2024
81f0c83
Increased unit test coverage for pkg/protocol/header_test (#1074)
XiaoYi-byte Mar 8, 2024
b7cbc9d
feat: add SetHandlers when fast fail for no valid host and invalid rP…
kingcanfish Mar 10, 2024
4742b2e
feat: add more default type
FGYFFFF Jan 30, 2024
3b3296c
feat: add more default type for binding (#1056)
FGYFFFF Apr 12, 2024
9858163
fix: import alias index "
lafer-fz Apr 16, 2024
3bc1be6
Merge branch 'develop' into refactor/client_query_enum
FGYFFFF Apr 18, 2024
0285a34
refactor(hz): client query enum (#1064)
FGYFFFF Apr 18, 2024
bd2a9b2
fix(hz): template import alias (#1093)
FGYFFFF Apr 19, 2024
637e0da
optimize: router_sort
FGYFFFF Aug 18, 2023
9a95dc8
optimize: router sort
FGYFFFF Apr 26, 2024
6f62cd9
optimize(hz): sort route strictly which preventing sorting inconsiste…
FGYFFFF May 9, 2024
b5b3f9d
feat: Add Partitioned Parameter to SetCookie (#1048)
Haswf May 9, 2024
2d13882
feat: add method to exile requestContext (#1101)
welkeyever May 9, 2024
a80eadb
fix: router sort (#1107)
FGYFFFF May 9, 2024
cbd63c6
fix: resp set trailer will panic (#1102)
wzekin May 10, 2024
ed4a8d8
chore(hz): release v090 (#1105)
FGYFFFF May 10, 2024
617fad8
chore: update version v0.9.0
alice-yyds May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ Hertz [həːts] is a high-usability, high-performance and high-extensibility Gol
The Hertz-Examples repository provides code out of the box. [more](https://www.cloudwego.io/zh/docs/hertz/tutorials/example/)
### Basic Features
Contains introduction and use of general middleware, context selection, data binding, data rendering, direct access, logging, error handling. [more](https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/)
### Observability
Contains instrumentation, logging, tracing, monitoring, OpenTelemetry integration. [more](https://www.cloudwego.io/docs/hertz/tutorials/observability/)
### Service Governance
Contains tracer monitor. [more](https://www.cloudwego.io/zh/docs/hertz/tutorials/service-governance/)
Contains service registration and discovery extensions, Sentinel integration. [more](https://www.cloudwego.io/zh/docs/hertz/tutorials/service-governance/)
### Framework Extension
Contains network library extensions. [more](https://www.cloudwego.io/zh/docs/hertz/tutorials/framework-exten/)
### Reference
Expand All @@ -51,10 +53,10 @@ Hertz [həːts] is a high-usability, high-performance and high-extensibility Gol
Frequently Asked Questions. [more](https://www.cloudwego.io/zh/docs/hertz/faq/)
## Performance
Performance testing can only provide a relative reference. In production, there are many factors that can affect actual performance.
We provide the hertz-benchmark project to track and compare the performance of Hertz and other frameworks in different situations for reference.
We provide the [hertz-benchmark](https://github.com/cloudwego/hertz-benchmark) project to track and compare the performance of Hertz and other frameworks in different situations for reference.
## Related Projects
- [Netpoll](https://github.com/cloudwego/netpoll): A high-performance network library. Hertz integrated by default.
- [Hertz-Contrib](https://github.com/hertz-contrib): A partial extension library of Hertz, which users can integrate into Hertz through options according to their needs.
- [Hertz-contrib](https://github.com/hertz-contrib): A partial extension library of Hertz, which users can integrate into Hertz through options according to their needs.
- [Example](https://github.com/cloudwego/hertz-examples): Use examples of Hertz.
## Extensions

Expand Down Expand Up @@ -120,7 +122,7 @@ Thank you for your contribution to Hertz!
## Landscapes

<p align="center">
<img src="https://landscape.cncf.io/images/left-logo.svg" width="150"/>&nbsp;&nbsp;<img src="https://landscape.cncf.io/images/right-logo.svg" width="200"/>
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" width="150"/>&nbsp;&nbsp;<img src="https://www.cncf.io/wp-content/uploads/2023/04/cncf-main-site-logo.svg" width="200"/>
<br/><br/>
CloudWeGo enriches the <a href="https://landscape.cncf.io/">CNCF CLOUD NATIVE Landscape</a>.
</p>
10 changes: 6 additions & 4 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ Hertz[həːts] 是一个 Golang 微服务 HTTP 框架,在设计之初参考了
### 用户指南
### 基本特性
包含通用中间件的介绍和使用,上下文选择,数据绑定,数据渲染,直连访问,日志,错误处理,[详见文档](https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/)
### 可观测性
包含日志,链路追踪,埋点,监控,OpenTelemetry 集成,[详见文档](https://www.cloudwego.io/zh/docs/hertz/tutorials/observability/)
### 治理特性
包含 trace monitor[详见文档](https://www.cloudwego.io/zh/docs/hertz/tutorials/service-governance/)
包含服务注册与发现扩展,Sentinel 集成[详见文档](https://www.cloudwego.io/zh/docs/hertz/tutorials/service-governance/)
### 框架扩展
包含网络库扩展,[详见文档](https://www.cloudwego.io/zh/docs/hertz/tutorials/framework-exten/)
### 参考
Expand All @@ -51,10 +53,10 @@ Hertz[həːts] 是一个 Golang 微服务 HTTP 框架,在设计之初参考了
常见问题排查,[详见文档](https://www.cloudwego.io/zh/docs/hertz/faq/)
## 框架性能
性能测试只能提供相对参考,工业场景下,有诸多因素可以影响实际的性能表现
我们提供了 hertz-benchmark 项目用来长期追踪和比较 Hertz 与其他框架在不同情况下的性能数据以供参考
我们提供了 [hertz-benchmark](https://github.com/cloudwego/hertz-benchmark) 项目用来长期追踪和比较 Hertz 与其他框架在不同情况下的性能数据以供参考
## 相关项目
- [Netpoll](https://github.com/cloudwego/netpoll): 自研高性能网络库,Hertz 默认集成
- [Hertz-Contrib](https://github.com/hertz-contrib): Hertz 扩展仓库,提供中间件、tracer 等能力
- [hertz-Contrib](https://github.com/hertz-contrib): Hertz 扩展仓库,提供可观测、安全、流量治理、协议、HTTP 通用能力等扩展
- [Example](https://github.com/cloudwego/hertz-examples): Hertz 使用例子
## 相关拓展

Expand Down Expand Up @@ -121,7 +123,7 @@ Hertz 基于[Apache License 2.0](https://github.com/cloudwego/hertz/blob/main/LI
## Landscapes

<p align="center">
<img src="https://landscape.cncf.io/images/left-logo.svg" width="150"/>&nbsp;&nbsp;<img src="https://landscape.cncf.io/images/right-logo.svg" width="200"/>
<img src="https://landscape.cncf.io/images/cncf-landscape-horizontal-color.svg" width="150"/>&nbsp;&nbsp;<img src="https://www.cncf.io/wp-content/uploads/2023/04/cncf-main-site-logo.svg" width="200"/>
<br/><br/>
CloudWeGo 丰富了 <a href="https://landscape.cncf.io/">CNCF 云原生生态</a>。
</p>
6 changes: 5 additions & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ HeaderReferer = "HeaderReferer"
expectedReferer = "expectedReferer"
Referer = "Referer"
O_WRONLY = "O_WRONLY"
WRONLY = "WRONLY"
WRONLY = "WRONLY"
ome = "ome"
ifModifiedSice = "ifModifiedSice"
hd = "hd"
pn = "pn"
5 changes: 5 additions & 0 deletions cmd/hz/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ func Init() *cli.App {
noRecurseFlag := cli.BoolFlag{Name: "no_recurse", Usage: "Generate master model only.", Destination: &globalArgs.NoRecurse}
forceNewFlag := cli.BoolFlag{Name: "force", Aliases: []string{"f"}, Usage: "Force new a project, which will overwrite the generated files", Destination: &globalArgs.ForceNew}
enableExtendsFlag := cli.BoolFlag{Name: "enable_extends", Usage: "Parse 'extends' for thrift IDL", Destination: &globalArgs.EnableExtends}
sortRouterFlag := cli.BoolFlag{Name: "sort_router", Usage: "Sort router register code, to avoid code difference", Destination: &globalArgs.SortRouter}

jsonEnumStrFlag := cli.BoolFlag{Name: "json_enumstr", Usage: "Use string instead of num for json enums when idl is thrift.", Destination: &globalArgs.JSONEnumStr}
queryEnumIntFlag := cli.BoolFlag{Name: "query_enumint", Usage: "Use num instead of string for query enum parameter.", Destination: &globalArgs.QueryEnumAsInt}
unsetOmitemptyFlag := cli.BoolFlag{Name: "unset_omitempty", Usage: "Remove 'omitempty' tag for generated struct.", Destination: &globalArgs.UnsetOmitempty}
protoCamelJSONTag := cli.BoolFlag{Name: "pb_camel_json_tag", Usage: "Convert Name style for json tag to camel(Only works protobuf).", Destination: &globalArgs.ProtobufCamelJSONTag}
snakeNameFlag := cli.BoolFlag{Name: "snake_tag", Usage: "Use snake_case style naming for tags. (Only works for 'form', 'query', 'json')", Destination: &globalArgs.SnakeName}
Expand Down Expand Up @@ -226,6 +228,7 @@ func Init() *cli.App {
&noRecurseFlag,
&forceNewFlag,
&enableExtendsFlag,
&sortRouterFlag,

&jsonEnumStrFlag,
&unsetOmitemptyFlag,
Expand Down Expand Up @@ -260,6 +263,7 @@ func Init() *cli.App {
&optPkgFlag,
&noRecurseFlag,
&enableExtendsFlag,
&sortRouterFlag,

&jsonEnumStrFlag,
&unsetOmitemptyFlag,
Expand Down Expand Up @@ -316,6 +320,7 @@ func Init() *cli.App {
&enableExtendsFlag,

&jsonEnumStrFlag,
&queryEnumIntFlag,
&unsetOmitemptyFlag,
&protoCamelJSONTag,
&snakeNameFlag,
Expand Down
2 changes: 2 additions & 0 deletions cmd/hz/config/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Argument struct {
NeedGoMod bool

JSONEnumStr bool
QueryEnumAsInt bool
UnsetOmitempty bool
ProtobufCamelJSONTag bool
ProtocOptions []string // options to pass through to protoc
Expand All @@ -71,6 +72,7 @@ type Argument struct {
ForceNew bool
SnakeStyleMiddleware bool
EnableExtends bool
SortRouter bool

CustomizeLayout string
CustomizeLayoutData string
Expand Down
6 changes: 6 additions & 0 deletions cmd/hz/generator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ type ClientMethod struct {
FormFileCode string
}

type ClientConfig struct {
QueryEnumAsInt bool
}

type ClientFile struct {
Config ClientConfig
FilePath string
PackageName string
ServiceName string
Expand Down Expand Up @@ -64,6 +69,7 @@ func (pkgGen *HttpPackageGenerator) genClient(pkg *HttpPackage, clientDir string
ServiceName: util.ToCamelCase(s.Name),
ClientMethods: s.ClientMethods,
BaseDomain: baseDomain,
Config: ClientConfig{QueryEnumAsInt: pkgGen.QueryEnumAsInt},
}
if !isExist {
err := pkgGen.TemplateGenerator.Generate(client, hertzClientTplName, hertzClientPath, false)
Expand Down
2 changes: 1 addition & 1 deletion cmd/hz/generator/custom_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func getInsertImportContent(tplInfo *Template, renderInfo interface{}, fileConte
}
imptSlice = append(imptSlice, [2]string{"", impt[1 : len(impt)-1]})
} else { // 3. alias "import"
idx := strings.Index(impt, "\n")
idx := strings.Index(impt, "\"")
if idx == -1 {
return nil, fmt.Errorf("error import format for file: %s", tplInfo.Path)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/hz/generator/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (pkgGen *HttpPackageGenerator) processHandler(handler *Handler, root *Route
}
handler.Imports[mm.PackageName] = mm
}
err := root.Update(m, handler.PackageName, singleHandlerPackage)
err := root.Update(m, handler.PackageName, singleHandlerPackage, pkgGen.SortRouter)
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/hz/generator/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ type HttpPackageGenerator struct {
IdlClientDir string // client dir for "client" command
ForceClientDir string // client dir without namespace for "client" command
BaseDomain string // request domain for "client" command
QueryEnumAsInt bool // client code use number for query parameter
ServiceGenDir string

NeedModel bool
HandlerByMethod bool // generate handler files with method dimension
SnakeStyleMiddleware bool // use snake name style for middleware
SortRouter bool

loadedBackend Backend
curModel *model.Model
Expand Down
32 changes: 14 additions & 18 deletions cmd/hz/generator/package_tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ type Option struct {

type Options struct {
hostUrl string
enumAsInt bool
doer client.Doer
header http.Header
requestBodyBind bindRequestBodyFunc
Expand Down Expand Up @@ -376,13 +375,6 @@ func WithResponseResultDecider(decider ResponseResultDecider) Option {
}}
}

// WithQueryEnumAsInt is used to set enum as int for query parameters
func WithQueryEnumAsInt(enable bool) Option {
return Option{func(op *Options) {
op.enumAsInt = enable
}}
}

func withHostUrl(HostUrl string) Option {
return Option{func(op *Options) {
op.hostUrl = HostUrl
Expand All @@ -392,7 +384,6 @@ func withHostUrl(HostUrl string) Option {
// underlying client
type cli struct {
hostUrl string
enumAsInt bool
doer client.Doer
header http.Header
bindRequestBody bindRequestBodyFunc
Expand Down Expand Up @@ -428,7 +419,6 @@ func newClient(opts *Options) (*cli, error) {

c := &cli{
hostUrl: opts.hostUrl,
enumAsInt: opts.enumAsInt,
doer: opts.doer,
header: opts.header,
bindRequestBody: opts.requestBodyBind,
Expand Down Expand Up @@ -505,12 +495,13 @@ func (c *cli) execute(req *request) (*response, error) {
// r get request
func (c *cli) r() *request {
return &request{
queryParam: url.Values{},
header: http.Header{},
pathParam: map[string]string{},
formParam: map[string]string{},
fileParam: map[string]string{},
client: c,
queryParam: url.Values{},
header: http.Header{},
pathParam: map[string]string{},
formParam: map[string]string{},
fileParam: map[string]string{},
client: c,
queryEnumAsInt: {{.Config.QueryEnumAsInt}},
}
}

Expand Down Expand Up @@ -556,6 +547,7 @@ type request struct {
client *cli
url string
method string
queryEnumAsInt bool
queryParam url.Values
header http.Header
pathParam map[string]string
Expand Down Expand Up @@ -601,10 +593,14 @@ func (r *request) setQueryParam(param string, value interface{}) *request {
switch v.Kind() {
case reflect.Slice, reflect.Array:
for index := 0; index < v.Len(); index++ {
r.queryParam.Add(param, fmt.Sprint(v.Index(index).Interface()))
if r.queryEnumAsInt && (v.Index(index).Kind() == reflect.Int32 || v.Index(index).Kind() == reflect.Int64) {
r.queryParam.Add(param, fmt.Sprintf("%d", v.Index(index).Interface()))
} else {
r.queryParam.Add(param, fmt.Sprint(v.Index(index).Interface()))
}
}
case reflect.Int32, reflect.Int64:
if r.client.enumAsInt {
if r.queryEnumAsInt {
r.queryParam.Add(param, fmt.Sprintf("%d", v.Interface()))
} else {
r.queryParam.Add(param, fmt.Sprint(v))
Expand Down
Loading
Loading