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

fix(pilota-build): init service should set cur item #237

Merged
merged 1 commit into from
Apr 8, 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
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
Loading