Skip to content

Commit

Permalink
fix(pilota-build): init service should set cur item
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWhiteWu committed Apr 7, 2024
1 parent 4c778b6 commit 74af635
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion 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 pilota-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pilota-build"
version = "0.11.0"
version = "0.11.1"
edition = "2021"
description = "Compile thrift and protobuf idl into rust code at compile-time."
documentation = "https://docs.rs/pilota-build"
Expand Down
40 changes: 21 additions & 19 deletions pilota-build/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,27 @@ where
/// get service information for volo-cli init, return path of service and
/// methods
pub fn get_init_service(&self, def_id: DefId) -> (String, String) {
let service_name = self.rust_name(def_id);
let mod_prefix = self.mod_path(def_id);
let service_path = format!(
"{}::{}",
mod_prefix.iter().map(|item| item.to_string()).join("::"),
service_name
);
tracing::debug!("service_path: {}", service_path);
let methods = self.service_methods(def_id);

let methods = methods
.iter()
.map(|m| {
self.backend
.codegen_service_method_with_global_path(def_id, m)
})
.join("\n");
CUR_ITEM.set(&def_id, || {
let service_name = self.rust_name(def_id);
let mod_prefix = self.mod_path(def_id);
let service_path = format!(
"{}::{}",
mod_prefix.iter().map(|item| item.to_string()).join("::"),
service_name
);
tracing::debug!("service_path: {}", service_path);
let methods = self.service_methods(def_id);

let methods = methods
.iter()
.map(|m| {
self.backend
.codegen_service_method_with_global_path(def_id, m)
})
.join("\n");

(service_path, methods)
(service_path, methods)
})
}

// pick first service as init service from idlservice
Expand Down Expand Up @@ -414,7 +416,7 @@ where
Self(v)
}}
}}
"#
});
self.backend.codegen_newtype_impl(def_id, stream, t);
Expand Down

0 comments on commit 74af635

Please sign in to comment.