diff --git a/.gitignore b/.gitignore index 6ae3d3c32..6494123b2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target/ **/*.rs.bk Cargo.lock tags +*/src/generated diff --git a/Cargo.toml b/Cargo.toml index 77b8463fa..bb175bba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ members = [ "tonic-reflection", "tonic-web", # Non-published crates "examples", - "codegen", "interop", # Tests "tests/disable_comments", "tests/included_service", diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE b/LICENSE-MIT similarity index 100% rename from LICENSE rename to LICENSE-MIT diff --git a/README.md b/README.md index afdd2b223..71bdec9aa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ RPC framework that puts mobile and HTTP/2 first. [![Crates.io](https://img.shields.io/crates/v/tonic)](https://crates.io/crates/tonic) [![Documentation](https://docs.rs/tonic/badge.svg)](https://docs.rs/tonic) -[![Crates.io](https://img.shields.io/crates/l/tonic)](LICENSE) +![Crates.io](https://img.shields.io/crates/l/tonic) [Examples] | [Website] | [Docs] | [Chat] @@ -124,7 +124,8 @@ project. ## License -This project is licensed under the [MIT license](LICENSE). +This project is licensed under the [MIT](LICENSE-MIT) and [Apache-2.0](LICENSE-APACHE) +licenses. ### Contribution diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml deleted file mode 100644 index f4d9f3290..000000000 --- a/codegen/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "codegen" -authors = ["Lucio Franco "] -license = "MIT" -edition = "2021" -publish = false -version = "0.1.0" - -[dependencies] -tempfile = "3.8.0" -tonic-build = {path = "../tonic-build", default-features = false, features = ["prost", "cleanup-markdown"]} diff --git a/examples/Cargo.toml b/examples/Cargo.toml index aea9133e1..fbcb2b20c 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Lucio Franco "] edition = "2021" -license = "MIT" +license = "MIT AND Apache-2.0" name = "examples" publish = false version = "0.1.0" diff --git a/examples/LICENSE b/examples/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/examples/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/examples/LICENSE-APACHE b/examples/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/examples/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/examples/LICENSE-MIT b/examples/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/examples/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/interop/Cargo.toml b/interop/Cargo.toml index 5ec668f4f..64096c45b 100644 --- a/interop/Cargo.toml +++ b/interop/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Lucio Franco "] edition = "2021" -license = "MIT" +license = "MIT AND Apache-2.0" name = "interop" publish = false version = "0.1.0" diff --git a/interop/LICENSE b/interop/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/interop/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/interop/LICENSE-APACHE b/interop/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/interop/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/interop/LICENSE-MIT b/interop/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/interop/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/tonic-build/LICENSE b/tonic-build/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/tonic-build/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tonic-build/LICENSE-MIT b/tonic-build/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/tonic-build/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/tonic-health/Cargo.toml b/tonic-health/Cargo.toml index 5591db3b3..1777d8b7e 100644 --- a/tonic-health/Cargo.toml +++ b/tonic-health/Cargo.toml @@ -8,16 +8,21 @@ documentation = "https://docs.rs/tonic-health/0.12.2" edition = "2021" homepage = "https://github.com/hyperium/tonic" keywords = ["rpc", "grpc", "async", "healthcheck"] -license = "MIT" +license = "MIT AND Apache-2.0" name = "tonic-health" readme = "README.md" repository = "https://github.com/hyperium/tonic" version = "0.12.2" +exclude = ["src/generated"] [features] default = ["transport"] transport = [] +[build-dependencies] +tempfile = "3.8.0" +tonic-build = {path = "../tonic-build", default-features = false, features = ["prost", "cleanup-markdown"]} + [dependencies] async-stream = "0.3" prost = "0.13" diff --git a/tonic-health/LICENSE b/tonic-health/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/tonic-health/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tonic-health/LICENSE-APACHE b/tonic-health/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/tonic-health/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/tonic-health/LICENSE-MIT b/tonic-health/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/tonic-health/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/tonic-health/build.rs b/tonic-health/build.rs new file mode 100644 index 000000000..8b3d40833 --- /dev/null +++ b/tonic-health/build.rs @@ -0,0 +1,68 @@ +use std::fs::create_dir; +use std::path::{Path, PathBuf}; + +fn main() { + codegen( + &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")), + &["proto/health.proto"], + &["proto"], + &PathBuf::from("src/generated"), + &PathBuf::from("src/generated/grpc_health_v1.bin"), + true, + true, + ); +} + +fn codegen( + root_dir: &Path, + iface_files: &[&str], + include_dirs: &[&str], + out_dir: &Path, + file_descriptor_set_path: &Path, + build_client: bool, + build_server: bool, +) { + let tempdir = tempfile::Builder::new() + .prefix("tonic-codegen-") + .tempdir() + .unwrap(); + + let iface_files: Vec = iface_files + .iter() + .map(|&path| root_dir.join(path)) + .collect(); + + let include_dirs: Vec = include_dirs + .iter() + .map(|&path| root_dir.join(path)) + .collect(); + let out_dir = root_dir.join(out_dir); + if !out_dir.exists() { + create_dir(out_dir.clone()).unwrap(); + } + + let file_descriptor_set_path = root_dir.join(file_descriptor_set_path); + + tonic_build::configure() + .build_client(build_client) + .build_server(build_server) + .out_dir(&tempdir) + .file_descriptor_set_path(file_descriptor_set_path) + .compile_protos(&iface_files, &include_dirs) + .unwrap(); + + for path in std::fs::read_dir(tempdir.path()).unwrap() { + let path = path.unwrap().path(); + let to = out_dir.join( + path.file_name() + .unwrap() + .to_str() + .unwrap() + .strip_suffix(".rs") + .unwrap() + .replace('.', "_") + + ".rs", + ); + std::fs::copy(&path, &to).unwrap(); + } +} diff --git a/tonic-health/src/generated/grpc_health_v1.bin b/tonic-health/src/generated/grpc_health_v1.bin deleted file mode 100644 index 52efb3122..000000000 Binary files a/tonic-health/src/generated/grpc_health_v1.bin and /dev/null differ diff --git a/tonic-health/src/generated/grpc_health_v1.rs b/tonic-health/src/generated/grpc_health_v1.rs deleted file mode 100644 index 428e32883..000000000 --- a/tonic-health/src/generated/grpc_health_v1.rs +++ /dev/null @@ -1,457 +0,0 @@ -// This file is @generated by prost-build. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct HealthCheckRequest { - #[prost(string, tag = "1")] - pub service: ::prost::alloc::string::String, -} -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct HealthCheckResponse { - #[prost(enumeration = "health_check_response::ServingStatus", tag = "1")] - pub status: i32, -} -/// Nested message and enum types in `HealthCheckResponse`. -pub mod health_check_response { - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum ServingStatus { - Unknown = 0, - Serving = 1, - NotServing = 2, - /// Used only by the Watch method. - ServiceUnknown = 3, - } - impl ServingStatus { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - ServingStatus::Unknown => "UNKNOWN", - ServingStatus::Serving => "SERVING", - ServingStatus::NotServing => "NOT_SERVING", - ServingStatus::ServiceUnknown => "SERVICE_UNKNOWN", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNKNOWN" => Some(Self::Unknown), - "SERVING" => Some(Self::Serving), - "NOT_SERVING" => Some(Self::NotServing), - "SERVICE_UNKNOWN" => Some(Self::ServiceUnknown), - _ => None, - } - } - } -} -/// Generated client implementations. -pub mod health_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct HealthClient { - inner: tonic::client::Grpc, - } - impl HealthClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + std::marker::Send + 'static, - ::Error: Into + std::marker::Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> HealthClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, - { - HealthClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /// If the requested service is unknown, the call will fail with status - /// NOT_FOUND. - pub async fn check( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/grpc.health.v1.Health/Check", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("grpc.health.v1.Health", "Check")); - self.inner.unary(req, path, codec).await - } - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. - /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. - /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. - pub async fn watch( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/grpc.health.v1.Health/Watch", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("grpc.health.v1.Health", "Watch")); - self.inner.server_streaming(req, path, codec).await - } - } -} -/// Generated server implementations. -pub mod health_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with HealthServer. - #[async_trait] - pub trait Health: std::marker::Send + std::marker::Sync + 'static { - /// If the requested service is unknown, the call will fail with status - /// NOT_FOUND. - async fn check( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Server streaming response type for the Watch method. - type WatchStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > - + std::marker::Send - + 'static; - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. - /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. - /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. - async fn watch( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - } - #[derive(Debug)] - pub struct HealthServer { - inner: Arc, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - impl HealthServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for HealthServer - where - T: Health, - B: Body + std::marker::Send + 'static, - B::Error: Into + std::marker::Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - match req.uri().path() { - "/grpc.health.v1.Health/Check" => { - #[allow(non_camel_case_types)] - struct CheckSvc(pub Arc); - impl< - T: Health, - > tonic::server::UnaryService - for CheckSvc { - type Response = super::HealthCheckResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::check(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = CheckSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/grpc.health.v1.Health/Watch" => { - #[allow(non_camel_case_types)] - struct WatchSvc(pub Arc); - impl< - T: Health, - > tonic::server::ServerStreamingService - for WatchSvc { - type Response = super::HealthCheckResponse; - type ResponseStream = T::WatchStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::watch(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = WatchSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.server_streaming(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - "grpc-status", - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } - } - } - } - impl Clone for HealthServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - /// Generated gRPC service name - pub const SERVICE_NAME: &str = "grpc.health.v1.Health"; - impl tonic::server::NamedService for HealthServer { - const NAME: &'static str = SERVICE_NAME; - } -} diff --git a/tonic-reflection/Cargo.toml b/tonic-reflection/Cargo.toml index 031293ace..450266a99 100644 --- a/tonic-reflection/Cargo.toml +++ b/tonic-reflection/Cargo.toml @@ -11,11 +11,12 @@ edition = "2021" homepage = "https://github.com/hyperium/tonic" documentation = "https://docs.rs/tonic-reflection/0.12.2" keywords = ["rpc", "grpc", "async", "reflection"] -license = "MIT" +license = "MIT AND Apache-2.0" name = "tonic-reflection" readme = "README.md" repository = "https://github.com/hyperium/tonic" version = "0.12.2" +exclude = ["src/generated"] [package.metadata.docs.rs] all-features = true @@ -25,6 +26,10 @@ rustdoc-args = ["--cfg", "docsrs"] server = ["prost-types", "dep:tokio", "dep:tokio-stream"] default = ["server"] +[build-dependencies] +tempfile = "3.8.0" +tonic-build = {path = "../tonic-build", default-features = false, features = ["prost", "cleanup-markdown"]} + [dependencies] prost = "0.13" prost-types = {version = "0.13", optional = true} diff --git a/tonic-reflection/LICENSE b/tonic-reflection/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/tonic-reflection/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tonic-reflection/LICENSE-APACHE b/tonic-reflection/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/tonic-reflection/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/tonic-reflection/LICENSE-MIT b/tonic-reflection/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/tonic-reflection/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/codegen/src/main.rs b/tonic-reflection/build.rs similarity index 64% rename from codegen/src/main.rs rename to tonic-reflection/build.rs index e67be9b4d..c6a62a31b 100644 --- a/codegen/src/main.rs +++ b/tonic-reflection/build.rs @@ -1,26 +1,9 @@ +use std::fs::create_dir; use std::path::{Path, PathBuf}; fn main() { - // tonic-health codegen( - &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")) - .parent() - .unwrap() - .join("tonic-health"), - &["proto/health.proto"], - &["proto"], - &PathBuf::from("src/generated"), - &PathBuf::from("src/generated/grpc_health_v1.bin"), - true, - true, - ); - - // tonic-reflection - codegen( - &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")) - .parent() - .unwrap() - .join("tonic-reflection"), + &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")), &["proto/reflection_v1.proto"], &["proto"], &PathBuf::from("src/generated"), @@ -29,10 +12,7 @@ fn main() { true, ); codegen( - &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")) - .parent() - .unwrap() - .join("tonic-reflection"), + &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")), &["proto/reflection_v1alpha.proto"], &["proto"], &PathBuf::from("src/generated"), @@ -40,20 +20,6 @@ fn main() { true, true, ); - - // tonic-types - codegen( - &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")) - .parent() - .unwrap() - .join("tonic-types"), - &["proto/status.proto", "proto/error_details.proto"], - &["proto"], - &PathBuf::from("src/generated"), - &PathBuf::from("src/generated/types.bin"), - false, - false, - ); } fn codegen( @@ -80,6 +46,9 @@ fn codegen( .map(|&path| root_dir.join(path)) .collect(); let out_dir = root_dir.join(out_dir); + if !out_dir.exists() { + create_dir(out_dir.clone()).unwrap(); + } let file_descriptor_set_path = root_dir.join(file_descriptor_set_path); tonic_build::configure() diff --git a/tonic-reflection/src/generated/grpc_reflection_v1.rs b/tonic-reflection/src/generated/grpc_reflection_v1.rs deleted file mode 100644 index 2f454728e..000000000 --- a/tonic-reflection/src/generated/grpc_reflection_v1.rs +++ /dev/null @@ -1,459 +0,0 @@ -// This file is @generated by prost-build. -/// The message sent by the client when calling ServerReflectionInfo method. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServerReflectionRequest { - #[prost(string, tag = "1")] - pub host: ::prost::alloc::string::String, - /// To use reflection service, the client should set one of the following - /// fields in message_request. The server distinguishes requests by their - /// defined field and then handles them using corresponding methods. - #[prost(oneof = "server_reflection_request::MessageRequest", tags = "3, 4, 5, 6, 7")] - pub message_request: ::core::option::Option< - server_reflection_request::MessageRequest, - >, -} -/// Nested message and enum types in `ServerReflectionRequest`. -pub mod server_reflection_request { - /// To use reflection service, the client should set one of the following - /// fields in message_request. The server distinguishes requests by their - /// defined field and then handles them using corresponding methods. - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum MessageRequest { - /// Find a proto file by the file name. - #[prost(string, tag = "3")] - FileByFilename(::prost::alloc::string::String), - /// Find the proto file that declares the given fully-qualified symbol name. - /// This field should be a fully-qualified symbol name - /// (e.g. .\[.\] or .). - #[prost(string, tag = "4")] - FileContainingSymbol(::prost::alloc::string::String), - /// Find the proto file which defines an extension extending the given - /// message type with the given field number. - #[prost(message, tag = "5")] - FileContainingExtension(super::ExtensionRequest), - /// Finds the tag numbers used by all known extensions of the given message - /// type, and appends them to ExtensionNumberResponse in an undefined order. - /// Its corresponding method is best-effort: it's not guaranteed that the - /// reflection service will implement this method, and it's not guaranteed - /// that this method will provide all extensions. Returns - /// StatusCode::UNIMPLEMENTED if it's not implemented. - /// This field should be a fully-qualified type name. The format is - /// . - #[prost(string, tag = "6")] - AllExtensionNumbersOfType(::prost::alloc::string::String), - /// List the full names of registered services. The content will not be - /// checked. - #[prost(string, tag = "7")] - ListServices(::prost::alloc::string::String), - } -} -/// The type name and extension number sent by the client when requesting -/// file_containing_extension. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExtensionRequest { - /// Fully-qualified type name. The format should be . - #[prost(string, tag = "1")] - pub containing_type: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub extension_number: i32, -} -/// The message sent by the server to answer ServerReflectionInfo method. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServerReflectionResponse { - #[prost(string, tag = "1")] - pub valid_host: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub original_request: ::core::option::Option, - /// The server sets one of the following fields according to the message_request - /// in the request. - #[prost(oneof = "server_reflection_response::MessageResponse", tags = "4, 5, 6, 7")] - pub message_response: ::core::option::Option< - server_reflection_response::MessageResponse, - >, -} -/// Nested message and enum types in `ServerReflectionResponse`. -pub mod server_reflection_response { - /// The server sets one of the following fields according to the message_request - /// in the request. - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum MessageResponse { - /// This message is used to answer file_by_filename, file_containing_symbol, - /// file_containing_extension requests with transitive dependencies. - /// As the repeated label is not allowed in oneof fields, we use a - /// FileDescriptorResponse message to encapsulate the repeated fields. - /// The reflection service is allowed to avoid sending FileDescriptorProtos - /// that were previously sent in response to earlier requests in the stream. - #[prost(message, tag = "4")] - FileDescriptorResponse(super::FileDescriptorResponse), - /// This message is used to answer all_extension_numbers_of_type requests. - #[prost(message, tag = "5")] - AllExtensionNumbersResponse(super::ExtensionNumberResponse), - /// This message is used to answer list_services requests. - #[prost(message, tag = "6")] - ListServicesResponse(super::ListServiceResponse), - /// This message is used when an error occurs. - #[prost(message, tag = "7")] - ErrorResponse(super::ErrorResponse), - } -} -/// Serialized FileDescriptorProto messages sent by the server answering -/// a file_by_filename, file_containing_symbol, or file_containing_extension -/// request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FileDescriptorResponse { - /// Serialized FileDescriptorProto messages. We avoid taking a dependency on - /// descriptor.proto, which uses proto2 only features, by making them opaque - /// bytes instead. - #[prost(bytes = "vec", repeated, tag = "1")] - pub file_descriptor_proto: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, -} -/// A list of extension numbers sent by the server answering -/// all_extension_numbers_of_type request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExtensionNumberResponse { - /// Full name of the base type, including the package name. The format - /// is . - #[prost(string, tag = "1")] - pub base_type_name: ::prost::alloc::string::String, - #[prost(int32, repeated, tag = "2")] - pub extension_number: ::prost::alloc::vec::Vec, -} -/// A list of ServiceResponse sent by the server answering list_services request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListServiceResponse { - /// The information of each service may be expanded in the future, so we use - /// ServiceResponse message to encapsulate it. - #[prost(message, repeated, tag = "1")] - pub service: ::prost::alloc::vec::Vec, -} -/// The information of a single service used by ListServiceResponse to answer -/// list_services request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServiceResponse { - /// Full name of a registered service, including its package name. The format - /// is . - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, -} -/// The error code and error message sent by the server when an error occurs. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ErrorResponse { - /// This field uses the error codes defined in grpc::StatusCode. - #[prost(int32, tag = "1")] - pub error_code: i32, - #[prost(string, tag = "2")] - pub error_message: ::prost::alloc::string::String, -} -/// Generated client implementations. -pub mod server_reflection_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct ServerReflectionClient { - inner: tonic::client::Grpc, - } - impl ServerReflectionClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + std::marker::Send + 'static, - ::Error: Into + std::marker::Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> ServerReflectionClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, - { - ServerReflectionClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - pub async fn server_reflection_info( - &mut self, - request: impl tonic::IntoStreamingRequest< - Message = super::ServerReflectionRequest, - >, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo", - ); - let mut req = request.into_streaming_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "grpc.reflection.v1.ServerReflection", - "ServerReflectionInfo", - ), - ); - self.inner.streaming(req, path, codec).await - } - } -} -/// Generated server implementations. -pub mod server_reflection_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with ServerReflectionServer. - #[async_trait] - pub trait ServerReflection: std::marker::Send + std::marker::Sync + 'static { - /// Server streaming response type for the ServerReflectionInfo method. - type ServerReflectionInfoStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result< - super::ServerReflectionResponse, - tonic::Status, - >, - > - + std::marker::Send - + 'static; - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - async fn server_reflection_info( - &self, - request: tonic::Request>, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - } - #[derive(Debug)] - pub struct ServerReflectionServer { - inner: Arc, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - impl ServerReflectionServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for ServerReflectionServer - where - T: ServerReflection, - B: Body + std::marker::Send + 'static, - B::Error: Into + std::marker::Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - match req.uri().path() { - "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo" => { - #[allow(non_camel_case_types)] - struct ServerReflectionInfoSvc(pub Arc); - impl< - T: ServerReflection, - > tonic::server::StreamingService - for ServerReflectionInfoSvc { - type Response = super::ServerReflectionResponse; - type ResponseStream = T::ServerReflectionInfoStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::server_reflection_info( - &inner, - request, - ) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = ServerReflectionInfoSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.streaming(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - "grpc-status", - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } - } - } - } - impl Clone for ServerReflectionServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - /// Generated gRPC service name - pub const SERVICE_NAME: &str = "grpc.reflection.v1.ServerReflection"; - impl tonic::server::NamedService for ServerReflectionServer { - const NAME: &'static str = SERVICE_NAME; - } -} diff --git a/tonic-reflection/src/generated/grpc_reflection_v1alpha.rs b/tonic-reflection/src/generated/grpc_reflection_v1alpha.rs deleted file mode 100644 index 237312987..000000000 --- a/tonic-reflection/src/generated/grpc_reflection_v1alpha.rs +++ /dev/null @@ -1,459 +0,0 @@ -// This file is @generated by prost-build. -/// The message sent by the client when calling ServerReflectionInfo method. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServerReflectionRequest { - #[prost(string, tag = "1")] - pub host: ::prost::alloc::string::String, - /// To use reflection service, the client should set one of the following - /// fields in message_request. The server distinguishes requests by their - /// defined field and then handles them using corresponding methods. - #[prost(oneof = "server_reflection_request::MessageRequest", tags = "3, 4, 5, 6, 7")] - pub message_request: ::core::option::Option< - server_reflection_request::MessageRequest, - >, -} -/// Nested message and enum types in `ServerReflectionRequest`. -pub mod server_reflection_request { - /// To use reflection service, the client should set one of the following - /// fields in message_request. The server distinguishes requests by their - /// defined field and then handles them using corresponding methods. - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum MessageRequest { - /// Find a proto file by the file name. - #[prost(string, tag = "3")] - FileByFilename(::prost::alloc::string::String), - /// Find the proto file that declares the given fully-qualified symbol name. - /// This field should be a fully-qualified symbol name - /// (e.g. .\[.\] or .). - #[prost(string, tag = "4")] - FileContainingSymbol(::prost::alloc::string::String), - /// Find the proto file which defines an extension extending the given - /// message type with the given field number. - #[prost(message, tag = "5")] - FileContainingExtension(super::ExtensionRequest), - /// Finds the tag numbers used by all known extensions of extendee_type, and - /// appends them to ExtensionNumberResponse in an undefined order. - /// Its corresponding method is best-effort: it's not guaranteed that the - /// reflection service will implement this method, and it's not guaranteed - /// that this method will provide all extensions. Returns - /// StatusCode::UNIMPLEMENTED if it's not implemented. - /// This field should be a fully-qualified type name. The format is - /// . - #[prost(string, tag = "6")] - AllExtensionNumbersOfType(::prost::alloc::string::String), - /// List the full names of registered services. The content will not be - /// checked. - #[prost(string, tag = "7")] - ListServices(::prost::alloc::string::String), - } -} -/// The type name and extension number sent by the client when requesting -/// file_containing_extension. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExtensionRequest { - /// Fully-qualified type name. The format should be . - #[prost(string, tag = "1")] - pub containing_type: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub extension_number: i32, -} -/// The message sent by the server to answer ServerReflectionInfo method. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServerReflectionResponse { - #[prost(string, tag = "1")] - pub valid_host: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub original_request: ::core::option::Option, - /// The server sets one of the following fields according to the - /// message_request in the request. - #[prost(oneof = "server_reflection_response::MessageResponse", tags = "4, 5, 6, 7")] - pub message_response: ::core::option::Option< - server_reflection_response::MessageResponse, - >, -} -/// Nested message and enum types in `ServerReflectionResponse`. -pub mod server_reflection_response { - /// The server sets one of the following fields according to the - /// message_request in the request. - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum MessageResponse { - /// This message is used to answer file_by_filename, file_containing_symbol, - /// file_containing_extension requests with transitive dependencies. - /// As the repeated label is not allowed in oneof fields, we use a - /// FileDescriptorResponse message to encapsulate the repeated fields. - /// The reflection service is allowed to avoid sending FileDescriptorProtos - /// that were previously sent in response to earlier requests in the stream. - #[prost(message, tag = "4")] - FileDescriptorResponse(super::FileDescriptorResponse), - /// This message is used to answer all_extension_numbers_of_type requests. - #[prost(message, tag = "5")] - AllExtensionNumbersResponse(super::ExtensionNumberResponse), - /// This message is used to answer list_services requests. - #[prost(message, tag = "6")] - ListServicesResponse(super::ListServiceResponse), - /// This message is used when an error occurs. - #[prost(message, tag = "7")] - ErrorResponse(super::ErrorResponse), - } -} -/// Serialized FileDescriptorProto messages sent by the server answering -/// a file_by_filename, file_containing_symbol, or file_containing_extension -/// request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FileDescriptorResponse { - /// Serialized FileDescriptorProto messages. We avoid taking a dependency on - /// descriptor.proto, which uses proto2 only features, by making them opaque - /// bytes instead. - #[prost(bytes = "vec", repeated, tag = "1")] - pub file_descriptor_proto: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, -} -/// A list of extension numbers sent by the server answering -/// all_extension_numbers_of_type request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExtensionNumberResponse { - /// Full name of the base type, including the package name. The format - /// is . - #[prost(string, tag = "1")] - pub base_type_name: ::prost::alloc::string::String, - #[prost(int32, repeated, tag = "2")] - pub extension_number: ::prost::alloc::vec::Vec, -} -/// A list of ServiceResponse sent by the server answering list_services request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListServiceResponse { - /// The information of each service may be expanded in the future, so we use - /// ServiceResponse message to encapsulate it. - #[prost(message, repeated, tag = "1")] - pub service: ::prost::alloc::vec::Vec, -} -/// The information of a single service used by ListServiceResponse to answer -/// list_services request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServiceResponse { - /// Full name of a registered service, including its package name. The format - /// is . - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, -} -/// The error code and error message sent by the server when an error occurs. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ErrorResponse { - /// This field uses the error codes defined in grpc::StatusCode. - #[prost(int32, tag = "1")] - pub error_code: i32, - #[prost(string, tag = "2")] - pub error_message: ::prost::alloc::string::String, -} -/// Generated client implementations. -pub mod server_reflection_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct ServerReflectionClient { - inner: tonic::client::Grpc, - } - impl ServerReflectionClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + std::marker::Send + 'static, - ::Error: Into + std::marker::Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> ServerReflectionClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, - { - ServerReflectionClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - pub async fn server_reflection_info( - &mut self, - request: impl tonic::IntoStreamingRequest< - Message = super::ServerReflectionRequest, - >, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", - ); - let mut req = request.into_streaming_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "grpc.reflection.v1alpha.ServerReflection", - "ServerReflectionInfo", - ), - ); - self.inner.streaming(req, path, codec).await - } - } -} -/// Generated server implementations. -pub mod server_reflection_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with ServerReflectionServer. - #[async_trait] - pub trait ServerReflection: std::marker::Send + std::marker::Sync + 'static { - /// Server streaming response type for the ServerReflectionInfo method. - type ServerReflectionInfoStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result< - super::ServerReflectionResponse, - tonic::Status, - >, - > - + std::marker::Send - + 'static; - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - async fn server_reflection_info( - &self, - request: tonic::Request>, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - } - #[derive(Debug)] - pub struct ServerReflectionServer { - inner: Arc, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - impl ServerReflectionServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for ServerReflectionServer - where - T: ServerReflection, - B: Body + std::marker::Send + 'static, - B::Error: Into + std::marker::Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - match req.uri().path() { - "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo" => { - #[allow(non_camel_case_types)] - struct ServerReflectionInfoSvc(pub Arc); - impl< - T: ServerReflection, - > tonic::server::StreamingService - for ServerReflectionInfoSvc { - type Response = super::ServerReflectionResponse; - type ResponseStream = T::ServerReflectionInfoStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::server_reflection_info( - &inner, - request, - ) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = ServerReflectionInfoSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.streaming(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - "grpc-status", - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } - } - } - } - impl Clone for ServerReflectionServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - /// Generated gRPC service name - pub const SERVICE_NAME: &str = "grpc.reflection.v1alpha.ServerReflection"; - impl tonic::server::NamedService for ServerReflectionServer { - const NAME: &'static str = SERVICE_NAME; - } -} diff --git a/tonic-reflection/src/generated/reflection_v1.bin b/tonic-reflection/src/generated/reflection_v1.bin deleted file mode 100644 index 4b4ecaef9..000000000 Binary files a/tonic-reflection/src/generated/reflection_v1.bin and /dev/null differ diff --git a/tonic-reflection/src/generated/reflection_v1alpha1.bin b/tonic-reflection/src/generated/reflection_v1alpha1.bin deleted file mode 100644 index 62d18b45b..000000000 Binary files a/tonic-reflection/src/generated/reflection_v1alpha1.bin and /dev/null differ diff --git a/tonic-types/Cargo.toml b/tonic-types/Cargo.toml index 1511141c0..3e1f2287d 100644 --- a/tonic-types/Cargo.toml +++ b/tonic-types/Cargo.toml @@ -11,11 +11,16 @@ documentation = "https://docs.rs/tonic-types/0.12.2" edition = "2021" homepage = "https://github.com/hyperium/tonic" keywords = ["rpc", "grpc", "protobuf"] -license = "MIT" +license = "MIT AND Apache-2.0" name = "tonic-types" readme = "README.md" repository = "https://github.com/hyperium/tonic" version = "0.12.2" +exclude = ["src/generated"] + +[build-dependencies] +tempfile = "3.8.0" +tonic-build = {path = "../tonic-build", default-features = false, features = ["prost", "cleanup-markdown"]} [dependencies] prost = "0.13" diff --git a/tonic-types/LICENSE b/tonic-types/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/tonic-types/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tonic-types/LICENSE-APACHE b/tonic-types/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/tonic-types/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/tonic-types/LICENSE-MIT b/tonic-types/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/tonic-types/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/tonic-types/build.rs b/tonic-types/build.rs new file mode 100644 index 000000000..3a0ec46bc --- /dev/null +++ b/tonic-types/build.rs @@ -0,0 +1,67 @@ +use std::fs::create_dir; +use std::path::{Path, PathBuf}; + +fn main() { + codegen( + &PathBuf::from(std::env!("CARGO_MANIFEST_DIR")), + &["proto/status.proto", "proto/error_details.proto"], + &["proto"], + &PathBuf::from("src/generated"), + &PathBuf::from("src/generated/types.bin"), + false, + false, + ); +} + +fn codegen( + root_dir: &Path, + iface_files: &[&str], + include_dirs: &[&str], + out_dir: &Path, + file_descriptor_set_path: &Path, + build_client: bool, + build_server: bool, +) { + let tempdir = tempfile::Builder::new() + .prefix("tonic-codegen-") + .tempdir() + .unwrap(); + + let iface_files: Vec = iface_files + .iter() + .map(|&path| root_dir.join(path)) + .collect(); + + let include_dirs: Vec = include_dirs + .iter() + .map(|&path| root_dir.join(path)) + .collect(); + let out_dir = root_dir.join(out_dir); + if !out_dir.exists() { + create_dir(out_dir.clone()).unwrap(); + } + let file_descriptor_set_path = root_dir.join(file_descriptor_set_path); + + tonic_build::configure() + .build_client(build_client) + .build_server(build_server) + .out_dir(&tempdir) + .file_descriptor_set_path(file_descriptor_set_path) + .compile_protos(&iface_files, &include_dirs) + .unwrap(); + + for path in std::fs::read_dir(tempdir.path()).unwrap() { + let path = path.unwrap().path(); + let to = out_dir.join( + path.file_name() + .unwrap() + .to_str() + .unwrap() + .strip_suffix(".rs") + .unwrap() + .replace('.', "_") + + ".rs", + ); + std::fs::copy(&path, &to).unwrap(); + } +} diff --git a/tonic-types/src/generated/google_rpc.rs b/tonic-types/src/generated/google_rpc.rs deleted file mode 100644 index 856defa5c..000000000 --- a/tonic-types/src/generated/google_rpc.rs +++ /dev/null @@ -1,280 +0,0 @@ -// This file is @generated by prost-build. -/// The `Status` type defines a logical error model that is suitable for -/// different programming environments, including REST APIs and RPC APIs. It is -/// used by [gRPC](). Each `Status` message contains -/// three pieces of data: error code, error message, and error details. -/// -/// You can find out more about this error model and how to work with it in the -/// [API Design Guide](). -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Status { - /// The status code, which should be an enum value of \[google.rpc.Code\]\[google.rpc.Code\]. - #[prost(int32, tag = "1")] - pub code: i32, - /// A developer-facing error message, which should be in English. Any - /// user-facing error message should be localized and sent in the - /// \[google.rpc.Status.details\]\[google.rpc.Status.details\] field, or localized by the client. - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, - /// A list of messages that carry the error details. There is a common set of - /// message types for APIs to use. - #[prost(message, repeated, tag = "3")] - pub details: ::prost::alloc::vec::Vec<::prost_types::Any>, -} -/// Describes when the clients can retry a failed request. Clients could ignore -/// the recommendation here or retry when this information is missing from error -/// responses. -/// -/// It's always recommended that clients should use exponential backoff when -/// retrying. -/// -/// Clients should wait until `retry_delay` amount of time has passed since -/// receiving the error response before retrying. If retrying requests also -/// fail, clients should use an exponential backoff scheme to gradually increase -/// the delay between retries based on `retry_delay`, until either a maximum -/// number of retries have been reached or a maximum retry delay cap has been -/// reached. -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct RetryInfo { - /// Clients should wait at least this long between retrying the same request. - #[prost(message, optional, tag = "1")] - pub retry_delay: ::core::option::Option<::prost_types::Duration>, -} -/// Describes additional debugging info. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DebugInfo { - /// The stack trace entries indicating where the error occurred. - #[prost(string, repeated, tag = "1")] - pub stack_entries: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - /// Additional debugging information provided by the server. - #[prost(string, tag = "2")] - pub detail: ::prost::alloc::string::String, -} -/// Describes how a quota check failed. -/// -/// For example if a daily limit was exceeded for the calling project, -/// a service could respond with a QuotaFailure detail containing the project -/// id and the description of the quota limit that was exceeded. If the -/// calling project hasn't enabled the service in the developer console, then -/// a service could respond with the project id and set `service_disabled` -/// to true. -/// -/// Also see RetryInfo and Help types for other details about handling a -/// quota failure. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct QuotaFailure { - /// Describes all quota violations. - #[prost(message, repeated, tag = "1")] - pub violations: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `QuotaFailure`. -pub mod quota_failure { - /// A message type used to describe a single quota violation. For example, a - /// daily quota or a custom quota that was exceeded. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Violation { - /// The subject on which the quota check failed. - /// For example, "clientip:" or "project:". - #[prost(string, tag = "1")] - pub subject: ::prost::alloc::string::String, - /// A description of how the quota check failed. Clients can use this - /// description to find more about the quota configuration in the service's - /// public documentation, or find the relevant quota limit to adjust through - /// developer console. - /// - /// For example: "Service disabled" or "Daily Limit for read operations - /// exceeded". - #[prost(string, tag = "2")] - pub description: ::prost::alloc::string::String, - } -} -/// Describes the cause of the error with structured details. -/// -/// Example of an error when contacting the "pubsub.googleapis.com" API when it -/// is not enabled: -/// -/// ```text,json -/// { "reason": "API_DISABLED" -/// "domain": "googleapis.com" -/// "metadata": { -/// "resource": "projects/123", -/// "service": "pubsub.googleapis.com" -/// } -/// } -/// ``` -/// -/// This response indicates that the pubsub.googleapis.com API is not enabled. -/// -/// Example of an error that is returned when attempting to create a Spanner -/// instance in a region that is out of stock: -/// -/// ```text,json -/// { "reason": "STOCKOUT" -/// "domain": "spanner.googleapis.com", -/// "metadata": { -/// "availableRegions": "us-central1,us-east2" -/// } -/// } -/// ``` -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ErrorInfo { - /// The reason of the error. This is a constant value that identifies the - /// proximate cause of the error. Error reasons are unique within a particular - /// domain of errors. This should be at most 63 characters and match - /// /\[A-Z0-9\_\]+/. - #[prost(string, tag = "1")] - pub reason: ::prost::alloc::string::String, - /// The logical grouping to which the "reason" belongs. The error domain - /// is typically the registered service name of the tool or product that - /// generates the error. Example: "pubsub.googleapis.com". If the error is - /// generated by some common infrastructure, the error domain must be a - /// globally unique value that identifies the infrastructure. For Google API - /// infrastructure, the error domain is "googleapis.com". - #[prost(string, tag = "2")] - pub domain: ::prost::alloc::string::String, - /// Additional structured details about this error. - /// - /// Keys should match /\[a-zA-Z0-9-\_\]/ and be limited to 64 characters in - /// length. When identifying the current value of an exceeded limit, the units - /// should be contained in the key, not the value. For example, rather than - /// {"instanceLimit": "100/request"}, should be returned as, - /// {"instanceLimitPerRequest": "100"}, if the client exceeds the number of - /// instances that can be created in a single (batch) request. - #[prost(map = "string, string", tag = "3")] - pub metadata: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, -} -/// Describes what preconditions have failed. -/// -/// For example, if an RPC failed because it required the Terms of Service to be -/// acknowledged, it could list the terms of service violation in the -/// PreconditionFailure message. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PreconditionFailure { - /// Describes all precondition violations. - #[prost(message, repeated, tag = "1")] - pub violations: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `PreconditionFailure`. -pub mod precondition_failure { - /// A message type used to describe a single precondition failure. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Violation { - /// The type of PreconditionFailure. We recommend using a service-specific - /// enum type to define the supported precondition violation subjects. For - /// example, "TOS" for "Terms of Service violation". - #[prost(string, tag = "1")] - pub r#type: ::prost::alloc::string::String, - /// The subject, relative to the type, that failed. - /// For example, "google.com/cloud" relative to the "TOS" type would indicate - /// which terms of service is being referenced. - #[prost(string, tag = "2")] - pub subject: ::prost::alloc::string::String, - /// A description of how the precondition failed. Developers can use this - /// description to understand how to fix the failure. - /// - /// For example: "Terms of service not accepted". - #[prost(string, tag = "3")] - pub description: ::prost::alloc::string::String, - } -} -/// Describes violations in a client request. This error type focuses on the -/// syntactic aspects of the request. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BadRequest { - /// Describes all violations in a client request. - #[prost(message, repeated, tag = "1")] - pub field_violations: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `BadRequest`. -pub mod bad_request { - /// A message type used to describe a single bad request field. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct FieldViolation { - /// A path leading to a field in the request body. The value will be a - /// sequence of dot-separated identifiers that identify a protocol buffer - /// field. E.g., "field_violations.field" would identify this field. - #[prost(string, tag = "1")] - pub field: ::prost::alloc::string::String, - /// A description of why the request element is bad. - #[prost(string, tag = "2")] - pub description: ::prost::alloc::string::String, - } -} -/// Contains metadata about the request that clients can attach when filing a bug -/// or providing other forms of feedback. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RequestInfo { - /// An opaque string that should only be interpreted by the service generating - /// it. For example, it can be used to identify requests in the service's logs. - #[prost(string, tag = "1")] - pub request_id: ::prost::alloc::string::String, - /// Any data that was used to serve this request. For example, an encrypted - /// stack trace that can be sent back to the service provider for debugging. - #[prost(string, tag = "2")] - pub serving_data: ::prost::alloc::string::String, -} -/// Describes the resource that is being accessed. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ResourceInfo { - /// A name for the type of resource being accessed, e.g. "sql table", - /// "cloud storage bucket", "file", "Google calendar"; or the type URL - /// of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". - #[prost(string, tag = "1")] - pub resource_type: ::prost::alloc::string::String, - /// The name of the resource being accessed. For example, a shared calendar - /// name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current - /// error is \[google.rpc.Code.PERMISSION_DENIED\]\[google.rpc.Code.PERMISSION_DENIED\]. - #[prost(string, tag = "2")] - pub resource_name: ::prost::alloc::string::String, - /// The owner of the resource (optional). - /// For example, "user:" or "project:". - #[prost(string, tag = "3")] - pub owner: ::prost::alloc::string::String, - /// Describes what error is encountered when accessing this resource. - /// For example, updating a cloud project may require the `writer` permission - /// on the developer console project. - #[prost(string, tag = "4")] - pub description: ::prost::alloc::string::String, -} -/// Provides links to documentation or for performing an out of band action. -/// -/// For example, if a quota check failed with an error indicating the calling -/// project hasn't enabled the accessed service, this can contain a URL pointing -/// directly to the right place in the developer console to flip the bit. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Help { - /// URL(s) pointing to additional information on handling the current error. - #[prost(message, repeated, tag = "1")] - pub links: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `Help`. -pub mod help { - /// Describes a URL link. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Link { - /// Describes what the link offers. - #[prost(string, tag = "1")] - pub description: ::prost::alloc::string::String, - /// The URL of the link. - #[prost(string, tag = "2")] - pub url: ::prost::alloc::string::String, - } -} -/// Provides a localized error message that is safe to return to the user -/// which can be attached to an RPC error. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LocalizedMessage { - /// The locale used following the specification defined at - /// - /// Examples are: "en-US", "fr-CH", "es-MX" - #[prost(string, tag = "1")] - pub locale: ::prost::alloc::string::String, - /// The localized error message in the above locale. - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, -} diff --git a/tonic-types/src/generated/types.bin b/tonic-types/src/generated/types.bin deleted file mode 100644 index 8af4e92be..000000000 Binary files a/tonic-types/src/generated/types.bin and /dev/null differ diff --git a/tonic-web/LICENSE b/tonic-web/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/tonic-web/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tonic-web/LICENSE-MIT b/tonic-web/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/tonic-web/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index bf32e23c1..d4bf8e22d 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -17,7 +17,7 @@ documentation = "https://docs.rs/tonic/0.12.2" edition = "2021" homepage = "https://github.com/hyperium/tonic" keywords = ["rpc", "grpc", "async", "futures", "protobuf"] -license = "MIT" +license = "MIT AND APACHE-2.0" readme = "../README.md" repository = "https://github.com/hyperium/tonic" version = "0.12.2" diff --git a/tonic/LICENSE b/tonic/LICENSE deleted file mode 100644 index 307709840..000000000 --- a/tonic/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 Lucio Franco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tonic/LICENSE-APACHE b/tonic/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/tonic/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/tonic/LICENSE-MIT b/tonic/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/tonic/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file