feat(build): Add build_transport builder option (#1130)
This commit is contained in:
@@ -22,3 +22,7 @@ members = [
|
|||||||
"tests/compression",
|
"tests/compression",
|
||||||
"tonic-web/tests/integration",
|
"tonic-web/tests/integration",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
prost-build = { git = "https://github.com/tokio-rs/prost/", branch = "lucio/format" }
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ version = "0.8.2"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
prettyplease = { version = "0.1" }
|
prettyplease = { version = "0.1" }
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
prost-build = { version = "0.11", optional = true }
|
prost-build = { version = "0.11.1", optional = true }
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = "1.0"
|
syn = "1.0"
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ pub fn generate<T: Service>(
|
|||||||
emit_package: bool,
|
emit_package: bool,
|
||||||
proto_path: &str,
|
proto_path: &str,
|
||||||
compile_well_known_types: bool,
|
compile_well_known_types: bool,
|
||||||
|
build_transport: bool,
|
||||||
attributes: &Attributes,
|
attributes: &Attributes,
|
||||||
) -> TokenStream {
|
) -> TokenStream {
|
||||||
let service_ident = quote::format_ident!("{}Client", service.name());
|
let service_ident = quote::format_ident!("{}Client", service.name());
|
||||||
let client_mod = quote::format_ident!("{}_client", naive_snake_case(service.name()));
|
let client_mod = quote::format_ident!("{}_client", naive_snake_case(service.name()));
|
||||||
let methods = generate_methods(service, emit_package, proto_path, compile_well_known_types);
|
let methods = generate_methods(service, emit_package, proto_path, compile_well_known_types);
|
||||||
|
|
||||||
let connect = generate_connect(&service_ident);
|
let connect = generate_connect(&service_ident, build_transport);
|
||||||
let service_doc = generate_doc_comments(service.comment());
|
let service_doc = generate_doc_comments(service.comment());
|
||||||
|
|
||||||
let package = if emit_package { service.package() } else { "" };
|
let package = if emit_package { service.package() } else { "" };
|
||||||
@@ -109,8 +110,8 @@ pub fn generate<T: Service>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "transport")]
|
#[cfg(feature = "transport")]
|
||||||
fn generate_connect(service_ident: &syn::Ident) -> TokenStream {
|
fn generate_connect(service_ident: &syn::Ident, enabled: bool) -> TokenStream {
|
||||||
quote! {
|
let connect_impl = quote! {
|
||||||
impl #service_ident<tonic::transport::Channel> {
|
impl #service_ident<tonic::transport::Channel> {
|
||||||
/// Attempt to create a new client by connecting to a given endpoint.
|
/// Attempt to create a new client by connecting to a given endpoint.
|
||||||
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
|
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
|
||||||
@@ -122,11 +123,17 @@ fn generate_connect(service_ident: &syn::Ident) -> TokenStream {
|
|||||||
Ok(Self::new(conn))
|
Ok(Self::new(conn))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if enabled {
|
||||||
|
connect_impl
|
||||||
|
} else {
|
||||||
|
TokenStream::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "transport"))]
|
#[cfg(not(feature = "transport"))]
|
||||||
fn generate_connect(_service_ident: &syn::Ident) -> TokenStream {
|
fn generate_connect(_service_ident: &syn::Ident, _enabled: bool) -> TokenStream {
|
||||||
TokenStream::new()
|
TokenStream::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,6 +213,14 @@ fn generate_attributes<'a>(
|
|||||||
|
|
||||||
// Generate a singular line of a doc comment
|
// Generate a singular line of a doc comment
|
||||||
fn generate_doc_comment<S: AsRef<str>>(comment: S) -> TokenStream {
|
fn generate_doc_comment<S: AsRef<str>>(comment: S) -> TokenStream {
|
||||||
|
let comment = comment.as_ref();
|
||||||
|
|
||||||
|
let comment = if !comment.starts_with(" ") {
|
||||||
|
format!(" {}", comment)
|
||||||
|
} else {
|
||||||
|
comment.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
let mut doc_stream = TokenStream::new();
|
let mut doc_stream = TokenStream::new();
|
||||||
|
|
||||||
doc_stream.append(Ident::new("doc", Span::call_site()));
|
doc_stream.append(Ident::new("doc", Span::call_site()));
|
||||||
|
|||||||
@@ -367,6 +367,7 @@ impl ServiceGenerator {
|
|||||||
true, // emit_package,
|
true, // emit_package,
|
||||||
"", // proto_path, -- not used
|
"", // proto_path, -- not used
|
||||||
false, // compile_well_known_types, -- not used
|
false, // compile_well_known_types, -- not used
|
||||||
|
self.builder.build_transport,
|
||||||
&Attributes::default(),
|
&Attributes::default(),
|
||||||
);
|
);
|
||||||
self.clients.extend(client);
|
self.clients.extend(client);
|
||||||
@@ -409,6 +410,7 @@ impl ServiceGenerator {
|
|||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
build_server: bool,
|
build_server: bool,
|
||||||
build_client: bool,
|
build_client: bool,
|
||||||
|
build_transport: bool,
|
||||||
|
|
||||||
out_dir: Option<PathBuf>,
|
out_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
@@ -418,6 +420,7 @@ impl Default for Builder {
|
|||||||
Self {
|
Self {
|
||||||
build_server: true,
|
build_server: true,
|
||||||
build_client: true,
|
build_client: true,
|
||||||
|
build_transport: true,
|
||||||
out_dir: None,
|
out_dir: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -445,6 +448,15 @@ impl Builder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enable or disable generated clients and servers to have built-in tonic
|
||||||
|
/// transport features.
|
||||||
|
///
|
||||||
|
/// When the `transport` feature is disabled this does nothing.
|
||||||
|
pub fn build_transport(mut self, enable: bool) -> Self {
|
||||||
|
self.build_transport = enable;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the output directory to generate code to.
|
/// Set the output directory to generate code to.
|
||||||
///
|
///
|
||||||
/// Defaults to the `OUT_DIR` environment variable.
|
/// Defaults to the `OUT_DIR` environment variable.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ pub fn configure() -> Builder {
|
|||||||
Builder {
|
Builder {
|
||||||
build_client: true,
|
build_client: true,
|
||||||
build_server: true,
|
build_server: true,
|
||||||
|
build_transport: true,
|
||||||
file_descriptor_set_path: None,
|
file_descriptor_set_path: None,
|
||||||
out_dir: None,
|
out_dir: None,
|
||||||
extern_path: Vec::new(),
|
extern_path: Vec::new(),
|
||||||
@@ -172,6 +173,7 @@ impl prost_build::ServiceGenerator for ServiceGenerator {
|
|||||||
self.builder.emit_package,
|
self.builder.emit_package,
|
||||||
&self.builder.proto_path,
|
&self.builder.proto_path,
|
||||||
self.builder.compile_well_known_types,
|
self.builder.compile_well_known_types,
|
||||||
|
self.builder.build_transport,
|
||||||
&self.builder.client_attributes,
|
&self.builder.client_attributes,
|
||||||
);
|
);
|
||||||
self.clients.extend(client);
|
self.clients.extend(client);
|
||||||
@@ -214,6 +216,7 @@ impl prost_build::ServiceGenerator for ServiceGenerator {
|
|||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
pub(crate) build_client: bool,
|
pub(crate) build_client: bool,
|
||||||
pub(crate) build_server: bool,
|
pub(crate) build_server: bool,
|
||||||
|
pub(crate) build_transport: bool,
|
||||||
pub(crate) file_descriptor_set_path: Option<PathBuf>,
|
pub(crate) file_descriptor_set_path: Option<PathBuf>,
|
||||||
pub(crate) extern_path: Vec<(String, String)>,
|
pub(crate) extern_path: Vec<(String, String)>,
|
||||||
pub(crate) field_attributes: Vec<(String, String)>,
|
pub(crate) field_attributes: Vec<(String, String)>,
|
||||||
@@ -243,6 +246,15 @@ impl Builder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enable or disable generated clients and servers to have built-in tonic
|
||||||
|
/// transport features.
|
||||||
|
///
|
||||||
|
/// When the `transport` feature is disabled this does nothing.
|
||||||
|
pub fn build_transport(mut self, enable: bool) -> Self {
|
||||||
|
self.build_transport = enable;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Generate a file containing the encoded `prost_types::FileDescriptorSet` for protocol buffers
|
/// Generate a file containing the encoded `prost_types::FileDescriptorSet` for protocol buffers
|
||||||
/// modules. This is required for implementing gRPC Server Reflection.
|
/// modules. This is required for implementing gRPC Server Reflection.
|
||||||
pub fn file_descriptor_set_path(mut self, path: impl AsRef<Path>) -> Self {
|
pub fn file_descriptor_set_path(mut self, path: impl AsRef<Path>) -> Self {
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ fn generate_trait<T: Service>(
|
|||||||
) -> TokenStream {
|
) -> TokenStream {
|
||||||
let methods = generate_trait_methods(service, proto_path, compile_well_known_types);
|
let methods = generate_trait_methods(service, proto_path, compile_well_known_types);
|
||||||
let trait_doc = generate_doc_comment(&format!(
|
let trait_doc = generate_doc_comment(&format!(
|
||||||
"Generated trait containing gRPC methods that should be implemented for use with {}Server.",
|
" Generated trait containing gRPC methods that should be implemented for use with {}Server.",
|
||||||
service.name()
|
service.name()
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ fn generate_trait_methods<T: Service>(
|
|||||||
(false, true) => {
|
(false, true) => {
|
||||||
let stream = quote::format_ident!("{}Stream", method.identifier());
|
let stream = quote::format_ident!("{}Stream", method.identifier());
|
||||||
let stream_doc = generate_doc_comment(&format!(
|
let stream_doc = generate_doc_comment(&format!(
|
||||||
"Server streaming response type for the {} method.",
|
" Server streaming response type for the {} method.",
|
||||||
method.identifier()
|
method.identifier()
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ fn generate_trait_methods<T: Service>(
|
|||||||
(true, true) => {
|
(true, true) => {
|
||||||
let stream = quote::format_ident!("{}Stream", method.identifier());
|
let stream = quote::format_ident!("{}Stream", method.identifier());
|
||||||
let stream_doc = generate_doc_comment(&format!(
|
let stream_doc = generate_doc_comment(&format!(
|
||||||
"Server streaming response type for the {} method.",
|
" Server streaming response type for the {} method.",
|
||||||
method.identifier()
|
method.identifier()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct HealthCheckRequest {
|
pub struct HealthCheckRequest {
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub service: ::prost::alloc::string::String,
|
pub service: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct HealthCheckResponse {
|
pub struct HealthCheckResponse {
|
||||||
#[prost(enumeration="health_check_response::ServingStatus", tag="1")]
|
#[prost(enumeration = "health_check_response::ServingStatus", tag = "1")]
|
||||||
pub status: i32,
|
pub status: i32,
|
||||||
}
|
}
|
||||||
/// Nested message and enum types in `HealthCheckResponse`.
|
/// Nested message and enum types in `HealthCheckResponse`.
|
||||||
pub mod health_check_response {
|
pub mod health_check_response {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Debug,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
Hash,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
::prost::Enumeration
|
||||||
|
)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
pub enum ServingStatus {
|
pub enum ServingStatus {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
@@ -103,8 +113,8 @@ pub mod health_client {
|
|||||||
self.inner = self.inner.accept_compressed(encoding);
|
self.inner = self.inner.accept_compressed(encoding);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
///If the requested service is unknown, the call will fail with status
|
/// If the requested service is unknown, the call will fail with status
|
||||||
///NOT_FOUND.
|
/// NOT_FOUND.
|
||||||
pub async fn check(
|
pub async fn check(
|
||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
|
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
|
||||||
@@ -124,21 +134,21 @@ pub mod health_client {
|
|||||||
);
|
);
|
||||||
self.inner.unary(request.into_request(), path, codec).await
|
self.inner.unary(request.into_request(), path, codec).await
|
||||||
}
|
}
|
||||||
///Performs a watch for the serving status of the requested service.
|
/// Performs a watch for the serving status of the requested service.
|
||||||
///The server will immediately send back a message indicating the current
|
/// The server will immediately send back a message indicating the current
|
||||||
///serving status. It will then subsequently send a new message whenever
|
/// serving status. It will then subsequently send a new message whenever
|
||||||
///the service's serving status changes.
|
/// the service's serving status changes.
|
||||||
///
|
///
|
||||||
///If the requested service is unknown when the call is received, the
|
/// If the requested service is unknown when the call is received, the
|
||||||
///server will send a message setting the serving status to
|
/// server will send a message setting the serving status to
|
||||||
///SERVICE_UNKNOWN but will *not* terminate the call. If at some
|
/// SERVICE_UNKNOWN but will *not* terminate the call. If at some
|
||||||
///future point, the serving status of the service becomes known, the
|
/// future point, the serving status of the service becomes known, the
|
||||||
///server will send a new message with the service's serving status.
|
/// server will send a new message with the service's serving status.
|
||||||
///
|
///
|
||||||
///If the call terminates with status UNIMPLEMENTED, then clients
|
/// If the call terminates with status UNIMPLEMENTED, then clients
|
||||||
///should assume this method is not supported and should not retry the
|
/// should assume this method is not supported and should not retry the
|
||||||
///call. If the call terminates with any other status (including OK),
|
/// call. If the call terminates with any other status (including OK),
|
||||||
///clients should retry the call with appropriate exponential backoff.
|
/// clients should retry the call with appropriate exponential backoff.
|
||||||
pub async fn watch(
|
pub async fn watch(
|
||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
|
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
|
||||||
@@ -167,36 +177,36 @@ pub mod health_client {
|
|||||||
pub mod health_server {
|
pub mod health_server {
|
||||||
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
|
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
|
||||||
use tonic::codegen::*;
|
use tonic::codegen::*;
|
||||||
///Generated trait containing gRPC methods that should be implemented for use with HealthServer.
|
/// Generated trait containing gRPC methods that should be implemented for use with HealthServer.
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Health: Send + Sync + 'static {
|
pub trait Health: Send + Sync + 'static {
|
||||||
///If the requested service is unknown, the call will fail with status
|
/// If the requested service is unknown, the call will fail with status
|
||||||
///NOT_FOUND.
|
/// NOT_FOUND.
|
||||||
async fn check(
|
async fn check(
|
||||||
&self,
|
&self,
|
||||||
request: tonic::Request<super::HealthCheckRequest>,
|
request: tonic::Request<super::HealthCheckRequest>,
|
||||||
) -> Result<tonic::Response<super::HealthCheckResponse>, tonic::Status>;
|
) -> Result<tonic::Response<super::HealthCheckResponse>, tonic::Status>;
|
||||||
///Server streaming response type for the Watch method.
|
/// Server streaming response type for the Watch method.
|
||||||
type WatchStream: futures_core::Stream<
|
type WatchStream: futures_core::Stream<
|
||||||
Item = Result<super::HealthCheckResponse, tonic::Status>,
|
Item = Result<super::HealthCheckResponse, tonic::Status>,
|
||||||
>
|
>
|
||||||
+ Send
|
+ Send
|
||||||
+ 'static;
|
+ 'static;
|
||||||
///Performs a watch for the serving status of the requested service.
|
/// Performs a watch for the serving status of the requested service.
|
||||||
///The server will immediately send back a message indicating the current
|
/// The server will immediately send back a message indicating the current
|
||||||
///serving status. It will then subsequently send a new message whenever
|
/// serving status. It will then subsequently send a new message whenever
|
||||||
///the service's serving status changes.
|
/// the service's serving status changes.
|
||||||
///
|
///
|
||||||
///If the requested service is unknown when the call is received, the
|
/// If the requested service is unknown when the call is received, the
|
||||||
///server will send a message setting the serving status to
|
/// server will send a message setting the serving status to
|
||||||
///SERVICE_UNKNOWN but will *not* terminate the call. If at some
|
/// SERVICE_UNKNOWN but will *not* terminate the call. If at some
|
||||||
///future point, the serving status of the service becomes known, the
|
/// future point, the serving status of the service becomes known, the
|
||||||
///server will send a new message with the service's serving status.
|
/// server will send a new message with the service's serving status.
|
||||||
///
|
///
|
||||||
///If the call terminates with status UNIMPLEMENTED, then clients
|
/// If the call terminates with status UNIMPLEMENTED, then clients
|
||||||
///should assume this method is not supported and should not retry the
|
/// should assume this method is not supported and should not retry the
|
||||||
///call. If the call terminates with any other status (including OK),
|
/// call. If the call terminates with any other status (including OK),
|
||||||
///clients should retry the call with appropriate exponential backoff.
|
/// clients should retry the call with appropriate exponential backoff.
|
||||||
async fn watch(
|
async fn watch(
|
||||||
&self,
|
&self,
|
||||||
request: tonic::Request<super::HealthCheckRequest>,
|
request: tonic::Request<super::HealthCheckRequest>,
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct Status {
|
pub struct Status {
|
||||||
/// The status code, which should be an enum value of \\[google.rpc.Code\]\[google.rpc.Code\\].
|
/// The status code, which should be an enum value of \\[google.rpc.Code\]\[google.rpc.Code\\].
|
||||||
#[prost(int32, tag="1")]
|
#[prost(int32, tag = "1")]
|
||||||
pub code: i32,
|
pub code: i32,
|
||||||
/// A developer-facing error message, which should be in English. Any
|
/// A developer-facing error message, which should be in English. Any
|
||||||
/// user-facing error message should be localized and sent in the
|
/// 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.
|
/// \\[google.rpc.Status.details\]\[google.rpc.Status.details\\] field, or localized by the client.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub message: ::prost::alloc::string::String,
|
pub message: ::prost::alloc::string::String,
|
||||||
/// A list of messages that carry the error details. There is a common set of
|
/// A list of messages that carry the error details. There is a common set of
|
||||||
/// message types for APIs to use.
|
/// message types for APIs to use.
|
||||||
#[prost(message, repeated, tag="3")]
|
#[prost(message, repeated, tag = "3")]
|
||||||
pub details: ::prost::alloc::vec::Vec<::prost_types::Any>,
|
pub details: ::prost::alloc::vec::Vec<::prost_types::Any>,
|
||||||
}
|
}
|
||||||
/// Describes when the clients can retry a failed request. Clients could ignore
|
/// Describes when the clients can retry a failed request. Clients could ignore
|
||||||
@@ -36,17 +36,17 @@ pub struct Status {
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct RetryInfo {
|
pub struct RetryInfo {
|
||||||
/// Clients should wait at least this long between retrying the same request.
|
/// Clients should wait at least this long between retrying the same request.
|
||||||
#[prost(message, optional, tag="1")]
|
#[prost(message, optional, tag = "1")]
|
||||||
pub retry_delay: ::core::option::Option<::prost_types::Duration>,
|
pub retry_delay: ::core::option::Option<::prost_types::Duration>,
|
||||||
}
|
}
|
||||||
/// Describes additional debugging info.
|
/// Describes additional debugging info.
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct DebugInfo {
|
pub struct DebugInfo {
|
||||||
/// The stack trace entries indicating where the error occurred.
|
/// The stack trace entries indicating where the error occurred.
|
||||||
#[prost(string, repeated, tag="1")]
|
#[prost(string, repeated, tag = "1")]
|
||||||
pub stack_entries: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
pub stack_entries: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||||
/// Additional debugging information provided by the server.
|
/// Additional debugging information provided by the server.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub detail: ::prost::alloc::string::String,
|
pub detail: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
/// Describes how a quota check failed.
|
/// Describes how a quota check failed.
|
||||||
@@ -63,7 +63,7 @@ pub struct DebugInfo {
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct QuotaFailure {
|
pub struct QuotaFailure {
|
||||||
/// Describes all quota violations.
|
/// Describes all quota violations.
|
||||||
#[prost(message, repeated, tag="1")]
|
#[prost(message, repeated, tag = "1")]
|
||||||
pub violations: ::prost::alloc::vec::Vec<quota_failure::Violation>,
|
pub violations: ::prost::alloc::vec::Vec<quota_failure::Violation>,
|
||||||
}
|
}
|
||||||
/// Nested message and enum types in `QuotaFailure`.
|
/// Nested message and enum types in `QuotaFailure`.
|
||||||
@@ -75,7 +75,7 @@ pub mod quota_failure {
|
|||||||
/// The subject on which the quota check failed.
|
/// The subject on which the quota check failed.
|
||||||
/// For example, "clientip:<ip address of client>" or "project:<Google
|
/// For example, "clientip:<ip address of client>" or "project:<Google
|
||||||
/// developer project id>".
|
/// developer project id>".
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub subject: ::prost::alloc::string::String,
|
pub subject: ::prost::alloc::string::String,
|
||||||
/// A description of how the quota check failed. Clients can use this
|
/// A description of how the quota check failed. Clients can use this
|
||||||
/// description to find more about the quota configuration in the service's
|
/// description to find more about the quota configuration in the service's
|
||||||
@@ -84,7 +84,7 @@ pub mod quota_failure {
|
|||||||
///
|
///
|
||||||
/// For example: "Service disabled" or "Daily Limit for read operations
|
/// For example: "Service disabled" or "Daily Limit for read operations
|
||||||
/// exceeded".
|
/// exceeded".
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub description: ::prost::alloc::string::String,
|
pub description: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ pub struct ErrorInfo {
|
|||||||
/// proximate cause of the error. Error reasons are unique within a particular
|
/// proximate cause of the error. Error reasons are unique within a particular
|
||||||
/// domain of errors. This should be at most 63 characters and match
|
/// domain of errors. This should be at most 63 characters and match
|
||||||
/// /\\[A-Z0-9\_\\]+/.
|
/// /\\[A-Z0-9\_\\]+/.
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub reason: ::prost::alloc::string::String,
|
pub reason: ::prost::alloc::string::String,
|
||||||
/// The logical grouping to which the "reason" belongs. The error domain
|
/// The logical grouping to which the "reason" belongs. The error domain
|
||||||
/// is typically the registered service name of the tool or product that
|
/// is typically the registered service name of the tool or product that
|
||||||
@@ -130,7 +130,7 @@ pub struct ErrorInfo {
|
|||||||
/// generated by some common infrastructure, the error domain must be a
|
/// generated by some common infrastructure, the error domain must be a
|
||||||
/// globally unique value that identifies the infrastructure. For Google API
|
/// globally unique value that identifies the infrastructure. For Google API
|
||||||
/// infrastructure, the error domain is "googleapis.com".
|
/// infrastructure, the error domain is "googleapis.com".
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub domain: ::prost::alloc::string::String,
|
pub domain: ::prost::alloc::string::String,
|
||||||
/// Additional structured details about this error.
|
/// Additional structured details about this error.
|
||||||
///
|
///
|
||||||
@@ -140,8 +140,11 @@ pub struct ErrorInfo {
|
|||||||
/// {"instanceLimit": "100/request"}, should be returned as,
|
/// {"instanceLimit": "100/request"}, should be returned as,
|
||||||
/// {"instanceLimitPerRequest": "100"}, if the client exceeds the number of
|
/// {"instanceLimitPerRequest": "100"}, if the client exceeds the number of
|
||||||
/// instances that can be created in a single (batch) request.
|
/// instances that can be created in a single (batch) request.
|
||||||
#[prost(map="string, string", tag="3")]
|
#[prost(map = "string, string", tag = "3")]
|
||||||
pub metadata: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
|
pub metadata: ::std::collections::HashMap<
|
||||||
|
::prost::alloc::string::String,
|
||||||
|
::prost::alloc::string::String,
|
||||||
|
>,
|
||||||
}
|
}
|
||||||
/// Describes what preconditions have failed.
|
/// Describes what preconditions have failed.
|
||||||
///
|
///
|
||||||
@@ -151,7 +154,7 @@ pub struct ErrorInfo {
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct PreconditionFailure {
|
pub struct PreconditionFailure {
|
||||||
/// Describes all precondition violations.
|
/// Describes all precondition violations.
|
||||||
#[prost(message, repeated, tag="1")]
|
#[prost(message, repeated, tag = "1")]
|
||||||
pub violations: ::prost::alloc::vec::Vec<precondition_failure::Violation>,
|
pub violations: ::prost::alloc::vec::Vec<precondition_failure::Violation>,
|
||||||
}
|
}
|
||||||
/// Nested message and enum types in `PreconditionFailure`.
|
/// Nested message and enum types in `PreconditionFailure`.
|
||||||
@@ -162,18 +165,18 @@ pub mod precondition_failure {
|
|||||||
/// The type of PreconditionFailure. We recommend using a service-specific
|
/// The type of PreconditionFailure. We recommend using a service-specific
|
||||||
/// enum type to define the supported precondition violation subjects. For
|
/// enum type to define the supported precondition violation subjects. For
|
||||||
/// example, "TOS" for "Terms of Service violation".
|
/// example, "TOS" for "Terms of Service violation".
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub r#type: ::prost::alloc::string::String,
|
pub r#type: ::prost::alloc::string::String,
|
||||||
/// The subject, relative to the type, that failed.
|
/// The subject, relative to the type, that failed.
|
||||||
/// For example, "google.com/cloud" relative to the "TOS" type would indicate
|
/// For example, "google.com/cloud" relative to the "TOS" type would indicate
|
||||||
/// which terms of service is being referenced.
|
/// which terms of service is being referenced.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub subject: ::prost::alloc::string::String,
|
pub subject: ::prost::alloc::string::String,
|
||||||
/// A description of how the precondition failed. Developers can use this
|
/// A description of how the precondition failed. Developers can use this
|
||||||
/// description to understand how to fix the failure.
|
/// description to understand how to fix the failure.
|
||||||
///
|
///
|
||||||
/// For example: "Terms of service not accepted".
|
/// For example: "Terms of service not accepted".
|
||||||
#[prost(string, tag="3")]
|
#[prost(string, tag = "3")]
|
||||||
pub description: ::prost::alloc::string::String,
|
pub description: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,7 +185,7 @@ pub mod precondition_failure {
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct BadRequest {
|
pub struct BadRequest {
|
||||||
/// Describes all violations in a client request.
|
/// Describes all violations in a client request.
|
||||||
#[prost(message, repeated, tag="1")]
|
#[prost(message, repeated, tag = "1")]
|
||||||
pub field_violations: ::prost::alloc::vec::Vec<bad_request::FieldViolation>,
|
pub field_violations: ::prost::alloc::vec::Vec<bad_request::FieldViolation>,
|
||||||
}
|
}
|
||||||
/// Nested message and enum types in `BadRequest`.
|
/// Nested message and enum types in `BadRequest`.
|
||||||
@@ -193,10 +196,10 @@ pub mod bad_request {
|
|||||||
/// A path leading to a field in the request body. The value will be a
|
/// 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
|
/// sequence of dot-separated identifiers that identify a protocol buffer
|
||||||
/// field. E.g., "field_violations.field" would identify this field.
|
/// field. E.g., "field_violations.field" would identify this field.
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub field: ::prost::alloc::string::String,
|
pub field: ::prost::alloc::string::String,
|
||||||
/// A description of why the request element is bad.
|
/// A description of why the request element is bad.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub description: ::prost::alloc::string::String,
|
pub description: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,11 +209,11 @@ pub mod bad_request {
|
|||||||
pub struct RequestInfo {
|
pub struct RequestInfo {
|
||||||
/// An opaque string that should only be interpreted by the service generating
|
/// 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.
|
/// it. For example, it can be used to identify requests in the service's logs.
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub request_id: ::prost::alloc::string::String,
|
pub request_id: ::prost::alloc::string::String,
|
||||||
/// Any data that was used to serve this request. For example, an encrypted
|
/// 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.
|
/// stack trace that can be sent back to the service provider for debugging.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub serving_data: ::prost::alloc::string::String,
|
pub serving_data: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
/// Describes the resource that is being accessed.
|
/// Describes the resource that is being accessed.
|
||||||
@@ -219,22 +222,22 @@ pub struct ResourceInfo {
|
|||||||
/// A name for the type of resource being accessed, e.g. "sql table",
|
/// A name for the type of resource being accessed, e.g. "sql table",
|
||||||
/// "cloud storage bucket", "file", "Google calendar"; or the type URL
|
/// "cloud storage bucket", "file", "Google calendar"; or the type URL
|
||||||
/// of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
|
/// of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub resource_type: ::prost::alloc::string::String,
|
pub resource_type: ::prost::alloc::string::String,
|
||||||
/// The name of the resource being accessed. For example, a shared calendar
|
/// The name of the resource being accessed. For example, a shared calendar
|
||||||
/// name: "[email protected]", if the current
|
/// name: "[email protected]", if the current
|
||||||
/// error is \\[google.rpc.Code.PERMISSION_DENIED\]\[google.rpc.Code.PERMISSION_DENIED\\].
|
/// error is \\[google.rpc.Code.PERMISSION_DENIED\]\[google.rpc.Code.PERMISSION_DENIED\\].
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub resource_name: ::prost::alloc::string::String,
|
pub resource_name: ::prost::alloc::string::String,
|
||||||
/// The owner of the resource (optional).
|
/// The owner of the resource (optional).
|
||||||
/// For example, "user:<owner email>" or "project:<Google developer project
|
/// For example, "user:<owner email>" or "project:<Google developer project
|
||||||
/// id>".
|
/// id>".
|
||||||
#[prost(string, tag="3")]
|
#[prost(string, tag = "3")]
|
||||||
pub owner: ::prost::alloc::string::String,
|
pub owner: ::prost::alloc::string::String,
|
||||||
/// Describes what error is encountered when accessing this resource.
|
/// Describes what error is encountered when accessing this resource.
|
||||||
/// For example, updating a cloud project may require the `writer` permission
|
/// For example, updating a cloud project may require the `writer` permission
|
||||||
/// on the developer console project.
|
/// on the developer console project.
|
||||||
#[prost(string, tag="4")]
|
#[prost(string, tag = "4")]
|
||||||
pub description: ::prost::alloc::string::String,
|
pub description: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
/// Provides links to documentation or for performing an out of band action.
|
/// Provides links to documentation or for performing an out of band action.
|
||||||
@@ -245,7 +248,7 @@ pub struct ResourceInfo {
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct Help {
|
pub struct Help {
|
||||||
/// URL(s) pointing to additional information on handling the current error.
|
/// URL(s) pointing to additional information on handling the current error.
|
||||||
#[prost(message, repeated, tag="1")]
|
#[prost(message, repeated, tag = "1")]
|
||||||
pub links: ::prost::alloc::vec::Vec<help::Link>,
|
pub links: ::prost::alloc::vec::Vec<help::Link>,
|
||||||
}
|
}
|
||||||
/// Nested message and enum types in `Help`.
|
/// Nested message and enum types in `Help`.
|
||||||
@@ -254,10 +257,10 @@ pub mod help {
|
|||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct Link {
|
pub struct Link {
|
||||||
/// Describes what the link offers.
|
/// Describes what the link offers.
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub description: ::prost::alloc::string::String,
|
pub description: ::prost::alloc::string::String,
|
||||||
/// The URL of the link.
|
/// The URL of the link.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub url: ::prost::alloc::string::String,
|
pub url: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,9 +271,9 @@ pub struct LocalizedMessage {
|
|||||||
/// The locale used following the specification defined at
|
/// The locale used following the specification defined at
|
||||||
/// <http://www.rfc-editor.org/rfc/bcp/bcp47.txt.>
|
/// <http://www.rfc-editor.org/rfc/bcp/bcp47.txt.>
|
||||||
/// Examples are: "en-US", "fr-CH", "es-MX"
|
/// Examples are: "en-US", "fr-CH", "es-MX"
|
||||||
#[prost(string, tag="1")]
|
#[prost(string, tag = "1")]
|
||||||
pub locale: ::prost::alloc::string::String,
|
pub locale: ::prost::alloc::string::String,
|
||||||
/// The localized error message in the above locale.
|
/// The localized error message in the above locale.
|
||||||
#[prost(string, tag="2")]
|
#[prost(string, tag = "2")]
|
||||||
pub message: ::prost::alloc::string::String,
|
pub message: ::prost::alloc::string::String,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user