Skip to content

Commit

Permalink
fix: codegen error caused by empty method of services
Browse files Browse the repository at this point in the history
  • Loading branch information
LYF1999 committed Aug 15, 2023
1 parent 7d36206 commit be94523
Showing 1 changed file with 15 additions and 4 deletions.
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 be94523

Please sign in to comment.