Skip to content

Commit

Permalink
Merge branch 'main' into tls
Browse files Browse the repository at this point in the history
  • Loading branch information
minghuaw committed Oct 26, 2023
2 parents 0d46a61 + f2ac0d4 commit 0910b14
Show file tree
Hide file tree
Showing 74 changed files with 689 additions and 867 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ repository = "https://github.com/cloudwego/volo"
license = "MIT OR Apache-2.0"

[workspace.dependencies]
pilota = "0.8"
pilota-build = "0.8"
pilota-thrift-parser = "0.4"
# 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" }
pilota = "0.9"
pilota-build = "0.9"
pilota-thrift-parser = "0.9"
#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.4"
#motore = { git = "https://github.com/cloudwego/motore", branch = "main" }

metainfo = "0.7"

anyhow = "1"
async-broadcast = "0.5"
async-broadcast = "0.6"
async-stream = "0.3"
async-trait = "0.1"
base64 = "0.13"
bytes = "1"
chrono = { version = "0.4", default-features = false, features = [
Expand Down Expand Up @@ -67,10 +67,10 @@ linked-hash-map = "0.5"
log = "0.4"
matchit = "0.7"
mur3 = "0.1"
nix = "0.26"
nix = "0.27"
nom = "7"
normpath = "1"
num_enum = "0.6"
num_enum = "0.7"
once_cell = "1"
parking_lot = "0.12"
paste = "1"
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
1 change: 0 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ path = "src/unknown/thrift_client.rs"
[dependencies]
anyhow.workspace = true
async-stream.workspace = true
async-trait.workspace = true
lazy_static.workspace = true
metainfo.workspace = true
tokio = { workspace = true, features = ["full"] }
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
3 changes: 0 additions & 3 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 All @@ -12,7 +10,6 @@ use volo_grpc::{

pub struct S;

#[volo::async_trait]
impl volo_gen::proto_gen::hello::Greeter for S {
async fn say_hello(
&self,
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
3 changes: 0 additions & 3 deletions examples/src/hello/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use volo_grpc::server::{Server, ServiceBuilder};

pub struct S;

#[volo::async_trait]
impl volo_gen::proto_gen::hello::Greeter for S {
async fn say_hello(
&self,
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
3 changes: 0 additions & 3 deletions examples/src/hello/thrift_server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

pub struct S;

#[volo::async_trait]
impl volo_gen::thrift_gen::hello::HelloService for S {
async fn hello(
&self,
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
3 changes: 0 additions & 3 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 All @@ -16,7 +14,6 @@ impl S {
}
}

#[volo::async_trait]
impl volo_gen::proto_gen::hello::Greeter for S {
async fn say_hello(
&self,
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
4 changes: 0 additions & 4 deletions examples/src/multiplex/grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

use volo_grpc::server::{Server, ServiceBuilder};

pub struct G;

#[volo::async_trait]
impl volo_gen::proto_gen::hello::Greeter for G {
async fn say_hello(
&self,
Expand All @@ -22,7 +19,6 @@ impl volo_gen::proto_gen::hello::Greeter for G {

pub struct E;

#[volo::async_trait]
impl volo_gen::proto_gen::echo::Echo for E {
async fn echo(
&self,
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
3 changes: 0 additions & 3 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 All @@ -12,7 +10,6 @@ use volo_grpc::{

pub struct S;

#[volo::async_trait]
impl volo_gen::proto_gen::streaming::Streaming for S {
async fn unary(
&self,
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
3 changes: 0 additions & 3 deletions examples/src/unknown/thrift_server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#![feature(impl_trait_in_assoc_type)]

use std::net::SocketAddr;

pub struct S;

#[volo::async_trait]
impl volo_gen::thrift_gen::echo_unknown::EchoService for S {
async fn hello(
&self,
Expand Down
1 change: 0 additions & 1 deletion examples/volo-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ publish = false

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
futures.workspace = true
tokio = { workspace = true, features = ["full"] }

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"
5 changes: 2 additions & 3 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.1"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand All @@ -17,12 +17,11 @@ 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

anyhow.workspace = true
async-trait.workspace = true
dirs.workspace = true
heck.workspace = true
itertools.workspace = true
Expand Down
25 changes: 11 additions & 14 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 Expand Up @@ -596,7 +590,10 @@ impl CodegenBackend for VoloGrpcBackend {

let name = self.cx().rust_name(method.def_id);

format!("async fn {name}(&self, {args}) -> ::std::result::Result<{ret_ty}>;")
format!(
"fn {name}(&self, {args}) -> impl ::std::future::Future<Output = \
::std::result::Result<{ret_ty}>> + Send;"
)
}

fn codegen_service_method_with_global_path(
Expand All @@ -614,7 +611,7 @@ impl CodegenBackend for VoloGrpcBackend {
let ty = self.trait_input_ty(a.ty.clone(), client_streaming, true);

let ident = &a.name;
// args are unsed, add _ to avoid unused variable warning
// args are unused, add _ to avoid unused variable warning
format!("_{ident}: {ty}")
})
.join(",");
Expand Down
Loading

0 comments on commit 0910b14

Please sign in to comment.