Skip to content

Commit

Permalink
docs: add release note for volo 0.10.0 (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
Millione authored Apr 8, 2024
1 parent 555306b commit 92ca635
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 0 deletions.
83 changes: 83 additions & 0 deletions content/en/blog/releases/Volo/release-v0100.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: 'Volo Release 0.10.0'
linkTitle: 'Release v0.10.0'
projects: ["Volo"]
date: 2024-04-08
description: >
---

In Volo 0.10.0, we mainly focused on extensibility and ease of use.

## Break Change

### Error Handling Refactored

Existing error types had issues such as unclear semantics, lack of maintainability and extensibility, and misuse. In the new version, we refactored the entire error handling, greatly enhancing the clarity and maintainability of error handling, and reducing misuse through the type system.

#### Migration Guide

##### Server Handler Migration

1. If previously using `anyhow::Result`, change `anyhow::Result` to `volo_thrift::ServerResult`:

```rust
async fn example(&self, req: XReq) -> volo_thrift::ServerResult<XResp>
```

2. If previously using Result<XResp, anyhow::Error>, replace anyhow::Error with volo_thrift::ServerError:

```rust
async fn example(&self, req: XReq) -> Result<XResp, volo_thrift::ServerError>
```

3. If you were using `Exception`, change the return type from `Result<XResp, volo_thrift::UserException<XException>>` to `Result<volo_thrift::MaybeException<XResp, XException>, volo_thrift::ServerError>`. At the same time, places that return `Err(UserError::UserException(exception))` should be changed to use `Ok(MaybeException::Exception(exception))`:

```rust
async fn example(&self, req: XReq) -> Result<volo_thrift::MaybeException<XResp, XException>, volo_thrift::ServerError> {
...
Ok(volo_thrift::MaybeException::Exception(exception))
}
```

4. If an error occurs when returning `anyhow::Error` after these changes, you can manually add a `.into()`:

```rust
return Err(anyhow::anyhow!(xxx).into())
```

5. If an error occurs at the `?` error return spot after these changes, you can try converting it to `anyhow::Error` before returning:

```rust
let x = xxx().map_err(|e|anyhow::anyhow!(e))?;
```

##### Service Middleware Migration

For middleware that is not aware of user errors, this change should not cause a breaking change. If you are aware of user errors, then just change the original `volo_thrift::Error` to `volo_thrift::ServerError/ClientError`.

##### Client Migration

The error part of the client has changed from `ResponseError` to `ClientError`. Just follow the compiler error message prompts to match the new error variant.


### IDL Management File volo.yml Format Refactored

The structure of the new yml configuration is clearer, easier to maintain, and mainly solves the issue that the old version could not support cross-repository referencing with git. The specific functions and configuration parameters can be seen [here](https://www.cloudwego.io/docs/volo/guide/config). In addition, for the volo-cli command-line tool, we have renamed the previous idl command to repo.

#### Migration Guide

Install the volo-cli v0.10.0 version and execute the volo migrate command in the volo.yml directory for automatic migration.


### Change in Default Generated Enum Type

In the newly generated code, the default generated Enum type has been changed to a newtype wrapping i32, in order to better support forward compatibility of modifications in the enumeration values of the IDL enum field.

#### Migration Guide

Just modify the enumeration name in the enum field to the corresponding generated name, such as `Foo::Bar` -> `Foo::BAR`.


## Complete Release Note

For the complete Release Note, please refer to: [Volo Changelog](https://github.com/cloudwego/volo/compare/volo-0.9.0...volo-0.10.0)
83 changes: 83 additions & 0 deletions content/zh/blog/releases/Volo/release-v0100.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: 'Volo 0.10.0 版本发布'
linkTitle: 'Release v0.10.0'
projects: ["Volo"]
date: 2024-04-08
description: >
---

Volo 0.10.0 版本中,我们更多的关注在了可扩展性和易用性上。

## Break Change

### 错误处理重构

原先的错误类型存在诸如语义不清晰、可维护性不强、可扩展性不强、容易误用等问题,因此在新版中,我们重构了整个错误处理部分,极大加强了错误处理部分的语义清晰度和可维护性,并通过类型系统降低误用概率。

#### 迁移指南

##### Server Handler 迁移

1. 如果原先使用 `anyhow::Result` 的,把 `anyhow:Result` 改为 `volo_thrift::ServerResult` 即可:

```rust
async fn example(&self, req: XReq) -> volo_thrift::ServerResult<XResp>
```

2. 如果原先使用 `Result<XResp, anyhow::Error>` 的,将 `anyhow::Error` 改为 `volo_thrift::ServerError` 即可:

```rust
async fn example(&self, req: XReq) -> Result<XResp, volo_thrift::ServerError>
```

3. 如果原先使用了 `Exception` 的用户,需要将返回类型从 `Result<XResp, volo_thrift::UserException<XException>>` 改为 `Result<volo_thrift::MaybeException<XResp, XException>, volo_thrift::ServerError>`,同时将原先返回 `Err(UserError::UserException(exception))` 的地方改为使用 `Ok(MaybeException::Exception(exception))` 即可:

```rust
async fn example(&self, req: XReq) -> Result<volo_thrift::MaybeException<XResp, XException>, volo_thrift::ServerError> {
...
Ok(volo_thrift::MaybeException::Exception(exception))
}
```

4. 如果改完之后,在返回 `anyhow::Error` 时出现报错,可以手动加一个 `.into()`

```rust
return Err(anyhow::anyhow!(xxx).into())
```

5. 如果改完之后,在 `?` 返回错误处出现报错,可以尝试先转换成 `anyhow::Error` 再返回。

```rust
let x = xxx().map_err(|e|anyhow::anyhow!(e))?;
```

##### Service 中间件迁移

对于不感知用户错误的中间件来说,本次修改应该不带来 break change;如果有需要感知用户错误,那么只需要把原来的 `volo_thrift::Error` 改为 `volo_thrift::ServerError/ClientError` 即可。

##### Client 迁移

client 部分的错误从原来的 `ResponseError` 改为了 `ClientError`,按编译器报错提示匹配新的错误 variant 即可。


### IDL 管理文件 volo.yml 格式重构

新版 yml 配置的结构更加清晰,且更易于维护,并主要解决了旧版中无法支持 git 跨仓库引用的问题,具体的功能和配置参数见 [config](https://www.cloudwego.io/zh/docs/volo/guide/config)。另外,对于 volo-cli 命令行工具,我们将之前的 idl 命令名字修改为了 repo。

#### 迁移指南

安装 volo-cli 0.10.0 版本,并在 volo.yml 目录下执行 volo migrate 命令即可自动迁移。


### 默认生成的 Enum 类型修改

在新版生成代码中,默认生成的 Enum 类型修改为了 i32 wrapper 的 newtype 类型,以便于更好的向前兼容 IDL enum 字段中枚举值的修改。

#### 迁移指南

将 enum 字段中枚举值名字修改为对应生成的名字即可,如 `Foo::Bar` -> `Foo::BAR`


## 完整 Release Note

完整的 Release Note 可以参考:[Volo Changelog](https://github.com/cloudwego/volo/compare/volo-0.9.0...volo-0.10.0)

0 comments on commit 92ca635

Please sign in to comment.