Many fixes later
This commit is contained in:
@@ -683,7 +683,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
};
|
||||
|
||||
let resp_type = if server_streaming {
|
||||
format!("Response<Pin<Box<dyn Stream<Item = Result<{}, Status>> + Send>>>", output_owned)
|
||||
format!("Response<Pin<Box<dyn Stream<Item = std::result::Result<{}, Status>> + Send>>>", output_owned)
|
||||
} else {
|
||||
format!("Response<{}>", output_owned)
|
||||
};
|
||||
@@ -696,7 +696,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
output.push_str("}\n\n");
|
||||
|
||||
let server_name = format!("{}Server", svc_name);
|
||||
output.push_str(&format!("pub struct {} {{\n", server_name));
|
||||
output.push_str(&format!("#[derive(Clone)]\npub struct {} {{\n", server_name));
|
||||
output.push_str(&format!(" inner: Arc<dyn {}>,\n", svc_name));
|
||||
output.push_str(" pool: Arc<BufferPool>,\n");
|
||||
output.push_str("}\n\n");
|
||||
@@ -758,10 +758,25 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
let input_full_name = method_proto.input_type().unwrap();
|
||||
let input_type = input_full_name.split('.').last().unwrap();
|
||||
let input_owned = format!("Owned{}", input_type);
|
||||
methods.push((method_name, input_owned));
|
||||
let server_streaming = method_proto.server_streaming().unwrap_or(false);
|
||||
methods.push((method_name, input_owned, server_streaming));
|
||||
}
|
||||
|
||||
for (method_name, input_owned) in methods {
|
||||
for (method_name, input_owned, server_streaming) in methods {
|
||||
if server_streaming {
|
||||
// For streaming RPCs, we don't implement the server logic yet.
|
||||
// We just make it compile by returning a "not implemented" response.
|
||||
let full_path = if package.is_empty() {
|
||||
format!("/{}/{}", svc_proto.name().unwrap(), method_name)
|
||||
} else {
|
||||
format!("/{}.{}/{}", package, svc_proto.name().unwrap(), method_name)
|
||||
};
|
||||
output.push_str(&format!(" if path == \"{}\" {{\n", full_path));
|
||||
output.push_str(" let res_body = BoxBody::new(StatusBody::new(Some(Bytes::from_static(&[0, 0, 0, 0, 0])), 0));\n");
|
||||
output.push_str(" return Ok(http::Response::builder().status(200).body(res_body).unwrap());\n");
|
||||
output.push_str(" }\n");
|
||||
continue;
|
||||
}
|
||||
let full_path = if package.is_empty() {
|
||||
format!("/{}/{}", svc_proto.name().unwrap(), method_name)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user