Skip to content

Commit

Permalink
feat: use afit and rpitit to optimize Service
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWhiteWu committed Oct 20, 2023
1 parent 1f27432 commit 0a0c5ae
Show file tree
Hide file tree
Showing 61 changed files with 779 additions and 1,014 deletions.
462 changes: 212 additions & 250 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ pilota = { git = "https://github.com/cloudwego/pilota", branch = "main" }
pilota-build = { git = "https://github.com/cloudwego/pilota", branch = "main" }
pilota-thrift-parser = { git = "https://github.com/cloudwego/pilota", branch = "main" }

motore = "0.3"
# motore = "0.3"
motore = { git = "https://github.com/cloudwego/motore", branch = "main" }

metainfo = "0.7"

Expand Down
12 changes: 6 additions & 6 deletions README-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

[English](README.md) | 中文

Volo 是字节跳动服务框架团队研发的 **高性能****可扩展性强** 的 Rust RPC 框架,使用了 Rust 最新的 GAT 特性。
Volo 是字节跳动服务框架团队研发的 **高性能****可扩展性强** 的 Rust RPC 框架,使用了 Rust 最新的 AFIT 和 RPITIT 特性。

Volo 使用 [`Motore`][motore] 作为其中间件抽象层, Motore 基于 GAT 设计。
Volo 使用 [`Motore`][motore] 作为其中间件抽象层, Motore 基于 AFIT 和 RPITIT 设计。

## 概览

Expand All @@ -30,11 +30,11 @@ Volo 主要包含 6 个 crate 库:

### 特点

#### 使用 GAT 特性
#### 使用 AFIT 和 RPITIT 特性

Volo 使用 [`Motore`][motore] 作为其中间件抽象层, Motore 基于 GAT 设计。
Volo 使用 [`Motore`][motore] 作为其中间件抽象层, Motore 基于 AFIT 和 RPITIT 设计。

通过 GAT,我们可以避免很多不必要的 Box 内存分配,以及提升易用性,给用户提供更友好的编程接口和更符合人体工程学的编程范式。
通过 RPITIT,我们可以避免很多不必要的 Box 内存分配,以及提升易用性,给用户提供更友好的编程接口和更符合人体工程学的编程范式。

#### 高性能

Expand Down Expand Up @@ -77,7 +77,7 @@ Volo-gRPC: https://www.cloudwego.io/zh/docs/volo/volo-grpc/getting-started/
## 相关生态

- [Volo-rs][volo-rs]: Volo 的相关生态,包含了 Volo 的许多组件
- [Motore][motore]: Volo 参考 Tower 设计的,使用了 GAT 的 middleware 抽象层
- [Motore][motore]: Volo 参考 Tower 设计的,使用了 AFIT 和 RPITIT 的 middleware 抽象层
- [Pilota][pilota]: Volo 使用的 Thrift 与 Protobuf 编译器及编解码的纯 Rust 实现(不依赖 protoc)
- [Metainfo][metainfo]: Volo 用于进行元信息透传的组件,期望定义一套元信息透传的标准

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ English | [中文](README-zh_cn.md)

Volo is a **high-performance** and **strong-extensibility** Rust RPC framework that helps developers build microservices.

Volo uses [`Motore`][motore] as its middleware abstraction, which is powered by GAT.
Volo uses [`Motore`][motore] as its middleware abstraction, which is powered by AFIT and RPITIT.

## Overview

Expand All @@ -30,11 +30,11 @@ Volo mainly consists of six crates:

### Features

#### Powered by GAT
#### Powered by AFIT and RPITIT

Volo uses [`Motore`][motore] as its middleware abstraction, which is powered by GAT.
Volo uses [`Motore`][motore] as its middleware abstraction, which is powered by AFIT and RPITIT.

Through GAT, we can avoid many unnecessary `Box` memory allocations, improve ease of use, and provide users with a more friendly programming interface and a more ergonomic programming paradigm.
Through RPITIT, we can avoid many unnecessary `Box` memory allocations, improve ease of use, and provide users with a more friendly programming interface and a more ergonomic programming paradigm.

#### High Performance

Expand Down Expand Up @@ -77,7 +77,7 @@ See [Examples][examples].
## Related Projects

- [Volo-rs][volo-rs]: The volo ecosystem which contains a lot of useful components.
- [Motore][motore]: Middleware abstraction layer powered by GAT.
- [Motore][motore]: Middleware abstraction layer powered by AFIT and RPITIT.
- [Pilota][pilota]: A thrift and protobuf implementation in pure rust with high performance and extensibility.
- [Metainfo][metainfo]: Transmissing metainfo across components.

Expand Down
2 changes: 0 additions & 2 deletions examples/src/compression/grpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use lazy_static::lazy_static;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/compression/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use volo_grpc::{
Expand Down
2 changes: 0 additions & 2 deletions examples/src/hello/grpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use lazy_static::lazy_static;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/hello/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use volo_grpc::server::{Server, ServiceBuilder};
Expand Down
2 changes: 0 additions & 2 deletions examples/src/hello/thrift_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use lazy_static::lazy_static;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/hello/thrift_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

pub struct S;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/loadbalance/grpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::{
cell::RefCell,
hash::{Hash, Hasher},
Expand Down
2 changes: 0 additions & 2 deletions examples/src/loadbalance/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use tokio::task;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/multiplex/grpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use lazy_static::lazy_static;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/multiplex/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use volo_grpc::server::{Server, ServiceBuilder};
Expand Down
2 changes: 0 additions & 2 deletions examples/src/streaming/grpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use async_stream::stream;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/streaming/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use tokio::sync::mpsc;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/unknown/thrift_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use lazy_static::lazy_static;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/unknown/thrift_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

pub struct S;
Expand Down
2 changes: 0 additions & 2 deletions examples/volo-gen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(impl_trait_in_assoc_type)]

mod gen {
volo::include_service!("thrift_gen.rs");
volo::include_service!("proto_gen.rs");
Expand Down
3 changes: 1 addition & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[toolchain]
# TODO: we can remove this toolchain file when TAIT hits stable.
# Related issue: https://github.com/rust-lang/rust/issues/63063.
# TODO: we can remove this toolchain file when AFIT and RPITIT hits stable.
channel = "nightly"
4 changes: 2 additions & 2 deletions volo-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-build"
version = "0.6.2"
version = "0.8.0"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand All @@ -17,7 +17,7 @@ keywords = ["thrift", "grpc", "protobuf", "volo", "build"]
maintenance = { status = "actively-developed" }

[dependencies]
volo = { version = "0.5", path = "../volo" }
volo = { version = "0.8", path = "../volo" }

pilota-build.workspace = true

Expand Down
18 changes: 6 additions & 12 deletions volo-build/src/grpc_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,20 +547,14 @@ impl CodegenBackend for VoloGrpcBackend {
{{
type Response = ::volo_grpc::Response<{resp_enum_name_send}>;
type Error = ::volo_grpc::status::Status;
type Future<'cx> = impl ::std::future::Future<Output = ::std::result::Result<Self::Response, Self::Error>> + 'cx;
fn call<'cx, 's>(&'s self, cx: &'cx mut ::volo_grpc::context::ServerContext, req: ::volo_grpc::Request<{req_enum_name_recv}>) -> Self::Future<'cx>
where
's: 'cx,
{{
async fn call<'s, 'cx>(&'s self, cx: &'cx mut ::volo_grpc::context::ServerContext, req: ::volo_grpc::Request<{req_enum_name_recv}>) -> ::std::result::Result<Self::Response, Self::Error> {{
let inner = self.inner.clone();
async move {{
match cx.rpc_info.method().unwrap().as_str() {{
{req_matches}
path => {{
let path = path.to_string();
Err(::volo_grpc::Status::unimplemented(::std::format!("Unimplemented http path: {{}}", path)))
}}
match cx.rpc_info.method().unwrap().as_str() {{
{req_matches}
path => {{
let path = path.to_string();
Err(::volo_grpc::Status::unimplemented(::std::format!("Unimplemented http path: {{}}", path)))
}}
}}
}}
Expand Down
10 changes: 3 additions & 7 deletions volo-build/src/thrift_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,9 @@ impl pilota_build::CodegenBackend for VoloThriftBackend {
type Response = {res_send_name};
type Error = ::anyhow::Error;
type Future<'cx> = impl ::std::future::Future<Output = ::std::result::Result<Self::Response, Self::Error>> + 'cx;
fn call<'cx, 's>(&'s self, _cx: &'cx mut ::volo_thrift::context::ServerContext, req: {req_recv_name}) -> Self::Future<'cx> where 's:'cx {{
async move {{
match req {{
{handler}
}}
async fn call<'s, 'cx>(&'s self, _cx: &'cx mut ::volo_thrift::context::ServerContext, req: {req_recv_name}) -> ::std::result::Result<Self::Response, Self::Error> {{
match req {{
{handler}
}}
}}
}}"#
Expand Down
4 changes: 2 additions & 2 deletions volo-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-cli"
version = "0.6.2"
version = "0.8.0"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand All @@ -22,7 +22,7 @@ keywords = ["thrift", "grpc", "protobuf", "volo", "cli"]
maintenance = { status = "actively-developed" }

[dependencies]
volo-build = { version = "0.6", path = "../volo-build" }
volo-build = { version = "0.8", path = "../volo-build" }
pilota-thrift-parser.workspace = true

anyhow.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions volo-cli/src/templates/grpc/rust-toolchain_toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[toolchain]
# TODO: we can remove this toolchain file when TAIT hits stable.
# Related issue: https://github.com/rust-lang/rust/issues/63063.
# TODO: we can remove this toolchain file when AFIT and RPITIT hits stable.
channel = "nightly"
2 changes: 1 addition & 1 deletion volo-cli/src/templates/grpc/src/bin/server_rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(impl_trait_in_assoc_type)]


use std::net::SocketAddr;

Expand Down
2 changes: 1 addition & 1 deletion volo-cli/src/templates/grpc/src/lib_rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(impl_trait_in_assoc_type)]


pub struct S;

Expand Down
2 changes: 1 addition & 1 deletion volo-cli/src/templates/grpc/volo-gen/src/lib_rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(impl_trait_in_assoc_type)]


mod gen {{
volo::include_service!("volo_gen.rs");
Expand Down
3 changes: 1 addition & 2 deletions volo-cli/src/templates/thrift/rust-toolchain_toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[toolchain]
# TODO: we can remove this toolchain file when TAIT hits stable.
# Related issue: https://github.com/rust-lang/rust/issues/63063.
# TODO: we can remove this toolchain file when AFIT and RPITIT hits stable.
channel = "nightly"
2 changes: 1 addition & 1 deletion volo-cli/src/templates/thrift/src/bin/server_rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(impl_trait_in_assoc_type)]


use std::net::SocketAddr;

Expand Down
2 changes: 1 addition & 1 deletion volo-cli/src/templates/thrift/src/lib_rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(impl_trait_in_assoc_type)]


pub struct S;

Expand Down
2 changes: 1 addition & 1 deletion volo-cli/src/templates/thrift/volo-gen/src/lib_rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(impl_trait_in_assoc_type)]


mod gen {{
volo::include_service!("volo_gen.rs");
Expand Down
4 changes: 2 additions & 2 deletions volo-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-grpc"
version = "0.6.0"
version = "0.8.0"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand All @@ -19,7 +19,7 @@ maintenance = { status = "actively-developed" }

[dependencies]
pilota.workspace = true
volo = { version = "0.5", path = "../volo" }
volo = { version = "0.8", path = "../volo" }
motore = { workspace = true, features = ["tower"] }
metainfo.workspace = true

Expand Down
Loading

0 comments on commit 0a0c5ae

Please sign in to comment.