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

Add an option to split generated pilota files #510

Merged
merged 18 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.vscode
.idea
target
/test
/benchmark/output
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ rust-version = "1.80.0"
pilota = "0.11"
pilota-build = "0.11"
pilota-thrift-parser = "0.11"
# 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 = { git = "https://github.com/cloudwego/pilota.git", branch = "main" }
# pilota-build = { git = "https://github.com/cloudwego/pilota.git", branch = "main" }
# pilota-thrift-parser = { git = "https://github.com/cloudwego/pilota.git", branch = "main" }

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

metainfo = "0.7"

Expand Down
1 change: 1 addition & 0 deletions examples/volo-gen/volo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ entries:
thrift:
filename: thrift_gen.rs
protocol: thrift
split_generated_files: true
services:
- idl:
source: local
Expand Down
9 changes: 9 additions & 0 deletions scripts/volo-cli-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ append_volo_dep_item() {
echo "$1 = { path = \"$VOLO_DIR/$1\" }" >> Cargo.toml
}

append_pilota_dep_item() {
echo "$1 = { git = \"https://github.com/cloudwego/pilota.git\", branch = \"main\" }" >> Cargo.toml
}

patch_cargo_toml() {
echo "[patch.crates-io]" >> Cargo.toml

append_volo_dep_item volo
append_volo_dep_item volo-build
append_volo_dep_item volo-thrift
append_volo_dep_item volo-grpc
append_volo_dep_item volo-http

append_pilota_dep_item pilota
append_pilota_dep_item pilota-build
append_pilota_dep_item pilota-thrift-parser
}

thrift_test() {
Expand Down
5 changes: 5 additions & 0 deletions tests/code-generation-workspace-split/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
common
rpc_article
rpc_author
rpc_image
Cargo.lock
37 changes: 37 additions & 0 deletions tests/code-generation-workspace-split/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[[bin]]
bench = false
name = "gen"
test = false

[dependencies.pilota-build]
version = "*"

[dependencies.volo-build]
workspace = true

[package]
edition = "2021"
name = "code-generation-workspace-split"
publish = false
version = "0.0.0"

[workspace]
members = []

[workspace.dependencies]
anyhow = "1"
async-trait = "0.1"
lazy_static = "1"
serde = "1"

[workspace.dependencies.pilota]
version = "*"

[workspace.dependencies.volo]
path = "../../volo"

[workspace.dependencies.volo-build]
path = "../../volo-build"

[workspace.dependencies.volo-thrift]
path = "../../volo-thrift"
7 changes: 7 additions & 0 deletions tests/code-generation-workspace-split/src/bin/gen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use volo_build::plugin::SerdePlugin;

fn main() {
volo_build::workspace::Builder::thrift()
.plugin(SerdePlugin)
.gen()
}
34 changes: 34 additions & 0 deletions tests/code-generation-workspace-split/thrift/article.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include "image.thrift"
include "author.thrift"
include "common.thrift"

namespace rs article

enum Status {
NORMAL = 0,
DELETED = 1,
}

struct Article {
1: required i64 id,
2: required string title,
3: required string content,
4: required author.Author author,
5: required Status status,
6: required list<image.Image> images,
7: required common.CommonData common_data,
}

struct GetArticleRequest {
1: required i64 id,
}

struct GetArticleResponse {
1: required Article article,
}

service ArticleService {
GetArticleResponse GetArticle(1: GetArticleRequest req),
}

service articleService {}
24 changes: 24 additions & 0 deletions tests/code-generation-workspace-split/thrift/author.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include "image.thrift"
include "common.thrift"

namespace rs author

struct Author {
1: required i64 id,
2: required string username,
3: required string email,
4: required image.Image avatar,
5: required common.CommonData common_data,
}

struct GetAuthorRequest {
1: required i64 id,
}

struct GetAuthorResponse {
1: required Author author,
}

service AuthorService {
GetAuthorResponse GetAuthor(1: GetAuthorRequest req),
}
9 changes: 9 additions & 0 deletions tests/code-generation-workspace-split/thrift/cdn.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include "common.thrift"

namespace rs article.image.cdn

struct CDN {
1: required i64 id,
2: required string url,
3: required common.CommonData common_data,
}
7 changes: 7 additions & 0 deletions tests/code-generation-workspace-split/thrift/common.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace rs common

struct CommonData {
1: required i64 id,
2: required string name,
3: required string description,
}
23 changes: 23 additions & 0 deletions tests/code-generation-workspace-split/thrift/image.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
include "common.thrift"
include "cdn.thrift"

namespace rs article.image

struct Image {
1: required i64 id,
2: required string url,
3: required cdn.CDN cdn,
4: required common.CommonData common_data,
}

struct GetImageRequest {
1: required i64 id,
}

struct GetImageResponse {
1: required Image image,
}

service ImageService {
GetImageResponse GetImage(1: GetImageRequest req),
}
Loading
Loading