Skip to content

Commit

Permalink
fix: codegen error caused by empty method of services (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
LYF1999 authored Aug 15, 2023
1 parent 7d36206 commit fad8d4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
17 changes: 4 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion 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.0"
version = "0.6.1"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
19 changes: 15 additions & 4 deletions volo-build/src/thrift_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ impl VoloThriftBackend {
let decode = mk_decode(false);
let decode_async = mk_decode(true);

let match_encode = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::pilota::thrift::Message::encode(value, protocol).map_err(|err| err.into())}}");
let match_size = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::volo_thrift::Message::size(value, protocol)}}");
let mut match_encode = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::pilota::thrift::Message::encode(value, protocol).map_err(|err| err.into())}}");
let mut match_size = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::volo_thrift::Message::size(value, protocol)}}");

if variant_names.is_empty() {
match_encode = "_ => unreachable!(),".to_string();
match_size = "_ => unreachable!(),".to_string();
}

format! {
r#"#[::async_trait::async_trait]
impl ::volo_thrift::EntryMessage for {req_recv_name} {{
Expand Down Expand Up @@ -140,8 +146,13 @@ impl VoloThriftBackend {
)
};

let match_encode = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::pilota::thrift::Message::encode(value, protocol).map_err(|err| err.into())}}");
let match_size = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::volo_thrift::Message::size(value, protocol)}}");
let mut match_encode = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::pilota::thrift::Message::encode(value, protocol).map_err(|err| err.into())}}");
let mut match_size = crate::join_multi_strs!(",", |variant_names| -> "Self::{variant_names}(value) => {{::volo_thrift::Message::size(value, protocol)}}");

if variant_names.is_empty() {
match_encode = "_ => unreachable!(),".to_string();
match_size = "_ => unreachable!(),".to_string();
}

let decode = mk_decode(false);
let decode_async = mk_decode(true);
Expand Down

0 comments on commit fad8d4e

Please sign in to comment.