-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to split generated pilota files (#510)
* Add an option to split generated pilota files Fixes #454 * Add missing field * Add tests/code-generation-split * add workspace split test * add workspace split generated code * add .gitignore * Formater fixes * Split services generated by volo into several files * Split each enums into a separate file * Split service into server and client * support deduplicate service * Review fixes * Use main pilota branch again * Ignore generated files in tests/code-generation-workspace-split * fix clippy * fix ci * update cli test dependencies * bump version --------- Co-authored-by: Millione <[email protected]>
- Loading branch information
1 parent
661346b
commit 70b9da7
Showing
23 changed files
with
469 additions
and
71 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.vscode | ||
.idea | ||
target | ||
/test | ||
/benchmark/output |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,5 @@ | ||
common | ||
rpc_article | ||
rpc_author | ||
rpc_image | ||
Cargo.lock |
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,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" |
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,7 @@ | ||
use volo_build::plugin::SerdePlugin; | ||
|
||
fn main() { | ||
volo_build::workspace::Builder::thrift() | ||
.plugin(SerdePlugin) | ||
.gen() | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/code-generation-workspace-split/thrift/article.thrift
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,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
24
tests/code-generation-workspace-split/thrift/author.thrift
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,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), | ||
} |
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,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, | ||
} |
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,7 @@ | ||
namespace rs common | ||
|
||
struct CommonData { | ||
1: required i64 id, | ||
2: required string name, | ||
3: required string description, | ||
} |
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,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), | ||
} |
Oops, something went wrong.