-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: "Hertz Release v0.7.0" | ||
linkTitle: "Release v0.7.0" | ||
projects: ["Hertz"] | ||
date: 2023-09-26 | ||
description: > | ||
--- | ||
|
||
In version 0.7.0 of Hertz, in addition to regular iterative optimization, we also brought several important features. | ||
|
||
## Refactor Binding | ||
In version 0.7.0 of Hertz,we refactored the binding feature for Hertz | ||
>https://github.com/cloudwego/hertz/pull/541 | ||
### Description Of Refactoring | ||
In version 0.7.0 of Hertz,we refactored the binding feature for Hertz to better support user requirements。This refactoring has the following characteristics: | ||
* Consistent functionality: | ||
- Binder: After the refactoring, we have implemented a default Binder within Hertz, which has the same functionality as before. The previous binding capabilities have been implemented as extensions under hertz-contrib. | ||
- Validator: We are still using go-tagexpr as the default implementation to ensure consistent functionality. | ||
* Converged configuration: | ||
- Before the refactoring, the behavior of parameter binding was mostly configured through global parameters, which could lead to conflicts when multiple components were configured. | ||
- After the refactoring, the binding and validation configurations are injected into the Hertz Engine through `BindConfig` and `ValidateConfig` struct using the 'WithOption' function. This not only unifies the configuration format but also avoids configuration conflicts. | ||
* Customizable Binder and Validator: | ||
- Custom Binder: You can use "WithCustomBinder" to inject your own custom Binder. We have already provided an extension called hertz-contrib/binding/go_tagexpr. | ||
- Custom Validator: You can use "WithCustomValidator" to inject your own custom Validator. We have also extended go-playground/validator for this purpose. | ||
* Performance improvements: The refactoring has resulted in improved binding performance compared to the previous version. Please refer to the benchmark data below for more details. | ||
|
||
|
||
### Usage | ||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/cloudwego/hertz/pkg/app/server/binding" | ||
"github.com/cloudwego/hertz/pkg/app/server" | ||
) | ||
|
||
func main() { | ||
bindConfig := binding.NewBindConfig() | ||
bindConfig.LooseZeroMode = true | ||
h := server.New(server.WithBindConfig(bindConfig)) | ||
... | ||
h.Spin() | ||
} | ||
``` | ||
|
||
### Benchmark Data | ||
https://github.com/cloudwego/hertz-benchmark/tree/main/binding | ||
|
||
## Full Release Note | ||
|
||
The complete Release Note can refer to: | ||
* Hertz: https://github.com/cloudwego/hertz/releases/tag/v0.7.0 | ||
* Hz(scaffolding): https://github.com/cloudwego/hertz/releases/tag/cmd%2Fhz%2Fv0.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: "Hertz v0.7.0 版本发布" | ||
linkTitle: "Release v0.7.0" | ||
projects: ["Hertz"] | ||
date: 2023-09-26 | ||
description: > | ||
--- | ||
|
||
Hertz v0.7.0 版本中,除了常规迭代优化之外,我们还带来了一个重要 feature。 | ||
|
||
## 参数绑定重构 | ||
在 Hertz v0.7.0 版本中,我们重构了 hertz 参数绑定 | ||
>https://github.com/cloudwego/hertz/pull/541 | ||
### 重构说明 | ||
在 Hertz v0.7.0 版本中,我们重构了参数绑定能力,将参数绑定能力收敛到框架本身,以更好地支持用户的需求。本次重构主要有以下特点: | ||
* 功能一致: | ||
- Binder:重构后在 Hertz 内部实现了一个默认的 Binder,其功能与重构前完全对齐,并将重构前的绑定能力以拓展的形式实现在 hertz-contrib 下 | ||
- Validator: 仍使用 go-tagexpr 作为默认实现,保证功能一致 | ||
* 配置收敛: | ||
- 重构前:参数绑定的行为大多通过全局参数的形式进行配置,可能导致多个组件出现配置冲突 | ||
- 重构后:以 BindConfig 和 ValidateConfig 的结构通过 'WithOption' 的形式注入到 Hertz Engine 中,既能统一配置形式,又能避免配置冲突的问题 | ||
* 可自定义 Binder 和 Validator: | ||
- 自定义 Binder:可使用 "WithCustomBinder" 来注入自定义的 Binder,目前已有拓展 hertz-contrib/binding/go_tagexpr | ||
- 自定义 Validator:可使用 "WithCustomValidator" 来注入自定义的 Validator,目前已经将 go-playground/validator 进行了拓展 | ||
* 性能提升:重构后绑定性能较之前有提升,详见后文压测数据 | ||
|
||
### 使用方法 | ||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/cloudwego/hertz/pkg/app/server/binding" | ||
"github.com/cloudwego/hertz/pkg/app/server" | ||
) | ||
|
||
func main() { | ||
bindConfig := binding.NewBindConfig() | ||
bindConfig.LooseZeroMode = true | ||
h := server.New(server.WithBindConfig(bindConfig)) | ||
... | ||
h.Spin() | ||
} | ||
``` | ||
|
||
### 压测数据 | ||
https://github.com/cloudwego/hertz-benchmark/tree/main/binding | ||
|
||
完整的 Release Note 可以参考: | ||
* Hertz: https://github.com/cloudwego/hertz/releases/tag/v0.7.0 | ||
* Hz(脚手架): https://github.com/cloudwego/hertz/releases/tag/cmd%2Fhz%2Fv0.7.0 |
f2eab33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cloudwego – ./
cloudwego.vercel.app
cloudwego-cloudwego.vercel.app
cloudwego-git-main-cloudwego.vercel.app
www.cloudwego.io
vercel.cloudwego.io
cloudwego.io