Skip to content

Commit

Permalink
Update Tonic to 0.6
Browse files Browse the repository at this point in the history
This brings in a new version of the gRPC library Tonic. This may help
fix some bugs[1] in status codes.

This also necessitates an upgrade to Prost 0.9. Protobuf-generated
sources have been updated, though it appears the only differences is
some doc formatting

[1]: hyperium/tonic#629
  • Loading branch information
rnarubin committed Jan 10, 2022
1 parent 8901ba3 commit aa3cb53
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 123 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ derive_more = { version = "0.99", optional = true }
hyper-openssl = { version = "0.9", optional = true }
hyper-rustls = { version = "0.22", features = ["rustls-native-certs"], optional = true }
pin-project = { version = "1", optional = true }
prost = { version = "0.8", optional = true }
prost-types = { version = "0.8", optional = true }
prost = { version = "0.9", optional = true }
prost-types = { version = "0.9", optional = true }
tame-gcs = { version = "0.10.0", optional = true }
tempdir = { version = "0.3", optional = true }
tokio = { version = "1", features = ["time"], optional = true }
tonic = { version = "0.5", optional = true }
tonic = { version = "0.6.2", optional = true }
tower = { version = "0.4", features = ["make"], optional = true }
uuid = { version = "0.8.1", features = ["v4"], optional = true }

Expand Down
4 changes: 2 additions & 2 deletions generators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ harness = false
[dependencies]
anyhow = "1"
flate2 = "1"
prost-build = "0.8"
prost-build = "0.9"
reqwest = { version = "0.11", features = ["blocking"] }
structopt = "0.3"
tar = "0.4"
tempfile = "3"
tonic-build = "0.5"
tonic-build = "0.6"

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
Expand Down
4 changes: 2 additions & 2 deletions src/auth/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ mod test {
struct InjectedError;

let mut auth_service = AuthGrpcService::new(
tonic::transport::Endpoint::from_static("localhost").connect_lazy()?,
tonic::transport::Endpoint::from_static("localhost").connect_lazy(),
Some(|| async { Err::<String, _>(InjectedError) }),
);

Expand All @@ -299,7 +299,7 @@ mod test {
struct InjectedError;

let mut auth_service = AuthGrpcService::new(
tonic::transport::Endpoint::from_static("localhost").connect_lazy()?,
tonic::transport::Endpoint::from_static("localhost").connect_lazy(),
Some(|| async { Ok::<_, std::io::Error>("\u{0000}") }),
);

Expand Down
119 changes: 29 additions & 90 deletions src/generated/google.api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Defines the HTTP configuration for an API service. It contains a list of
/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
/// \[HttpRule][google.api.HttpRule\], each specifying the mapping of an RPC method
/// to one or more HTTP REST API methods.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Http {
Expand All @@ -22,10 +22,10 @@ pub struct Http {
/// gRPC Transcoding is a feature for mapping between a gRPC method and one or
/// more HTTP REST endpoints. It allows developers to build a single API service
/// that supports both gRPC APIs and REST APIs. Many systems, including [Google
/// APIs](https://github.com/googleapis/googleapis),
/// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC
/// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),
/// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature
/// APIs](<https://github.com/googleapis/googleapis>),
/// [Cloud Endpoints](<https://cloud.google.com/endpoints>), [gRPC
/// Gateway](<https://github.com/grpc-ecosystem/grpc-gateway>),
/// and \[Envoy\](<https://github.com/envoyproxy/envoy>) proxy support this feature
/// and use it for large scale production services.
///
/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
Expand Down Expand Up @@ -186,15 +186,15 @@ pub struct Http {
/// 1. Leaf request fields (recursive expansion nested messages in the request
/// message) are classified into three categories:
/// - Fields referred by the path template. They are passed via the URL path.
/// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP
/// - Fields referred by the \[HttpRule.body][google.api.HttpRule.body\]. They are passed via the HTTP
/// request body.
/// - All other fields are passed via the URL query parameters, and the
/// parameter name is the field path in the request message. A repeated
/// field can be represented as multiple query parameters under the same
/// name.
/// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields
/// 2. If \[HttpRule.body][google.api.HttpRule.body\] is "*", there is no URL query parameter, all fields
/// are passed via URL path and HTTP request body.
/// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all
/// 3. If \[HttpRule.body][google.api.HttpRule.body\] is omitted, there is no HTTP request body, all
/// fields are passed via URL path and URL query parameters.
///
/// ### Path template syntax
Expand All @@ -221,19 +221,19 @@ pub struct Http {
///
/// If a variable contains exactly one path segment, such as `"{var}"` or
/// `"{var=*}"`, when such a variable is expanded into a URL path on the client
/// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The
/// side, all characters except `\[-_.~0-9a-zA-Z\]` are percent-encoded. The
/// server side does the reverse decoding. Such variables show up in the
/// [Discovery
/// Document](https://developers.google.com/discovery/v1/reference/apis) as
/// Document](<https://developers.google.com/discovery/v1/reference/apis>) as
/// `{var}`.
///
/// If a variable contains multiple path segments, such as `"{var=foo/*}"`
/// or `"{var=**}"`, when such a variable is expanded into a URL path on the
/// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.
/// client side, all characters except `\[-_.~/0-9a-zA-Z\]` are percent-encoded.
/// The server side does the reverse decoding, except "%2F" and "%2f" are left
/// unchanged. Such variables show up in the
/// [Discovery
/// Document](https://developers.google.com/discovery/v1/reference/apis) as
/// Document](<https://developers.google.com/discovery/v1/reference/apis>) as
/// `{+var}`.
///
/// ## Using gRPC API Service Configuration
Expand Down Expand Up @@ -263,10 +263,10 @@ pub struct Http {
///
/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
/// proto to JSON conversion must follow the [proto3
/// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).
/// specification](<https://developers.google.com/protocol-buffers/docs/proto3#json>).
///
/// While the single segment variable follows the semantics of
/// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String
/// [RFC 6570](<https://tools.ietf.org/html/rfc6570>) Section 3.2.2 Simple String
/// Expansion, the multi segment variable **does not** follow RFC 6570 Section
/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
/// does not expand special characters like `?` and `#`, which would lead
Expand All @@ -290,7 +290,7 @@ pub struct Http {
pub struct HttpRule {
/// Selects a method to which this rule applies.
///
/// Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
/// Refer to \[selector][google.api.DocumentationRule.selector\] for syntax details.
#[prost(string, tag = "1")]
pub selector: ::prost::alloc::string::String,
/// The name of the request field whose value is mapped to the HTTP request
Expand Down Expand Up @@ -418,22 +418,15 @@ pub enum FieldBehavior {
/// // For Kubernetes resources, the format is {api group}/{kind}.
/// option (google.api.resource) = {
/// type: "pubsub.googleapis.com/Topic"
/// name_descriptor: {
/// pattern: "projects/{project}/topics/{topic}"
/// parent_type: "cloudresourcemanager.googleapis.com/Project"
/// parent_name_extractor: "projects/{project}"
/// }
/// pattern: "projects/{project}/topics/{topic}"
/// };
/// }
///
/// The ResourceDescriptor Yaml config will look like:
///
/// resources:
/// - type: "pubsub.googleapis.com/Topic"
/// name_descriptor:
/// - pattern: "projects/{project}/topics/{topic}"
/// parent_type: "cloudresourcemanager.googleapis.com/Project"
/// parent_name_extractor: "projects/{project}"
/// pattern: "projects/{project}/topics/{topic}"
///
/// Sometimes, resources have multiple patterns, typically because they can
/// live under multiple parents.
Expand All @@ -443,75 +436,21 @@ pub enum FieldBehavior {
/// message LogEntry {
/// option (google.api.resource) = {
/// type: "logging.googleapis.com/LogEntry"
/// name_descriptor: {
/// pattern: "projects/{project}/logs/{log}"
/// parent_type: "cloudresourcemanager.googleapis.com/Project"
/// parent_name_extractor: "projects/{project}"
/// }
/// name_descriptor: {
/// pattern: "folders/{folder}/logs/{log}"
/// parent_type: "cloudresourcemanager.googleapis.com/Folder"
/// parent_name_extractor: "folders/{folder}"
/// }
/// name_descriptor: {
/// pattern: "organizations/{organization}/logs/{log}"
/// parent_type: "cloudresourcemanager.googleapis.com/Organization"
/// parent_name_extractor: "organizations/{organization}"
/// }
/// name_descriptor: {
/// pattern: "billingAccounts/{billing_account}/logs/{log}"
/// parent_type: "billing.googleapis.com/BillingAccount"
/// parent_name_extractor: "billingAccounts/{billing_account}"
/// }
/// pattern: "projects/{project}/logs/{log}"
/// pattern: "folders/{folder}/logs/{log}"
/// pattern: "organizations/{organization}/logs/{log}"
/// pattern: "billingAccounts/{billing_account}/logs/{log}"
/// };
/// }
///
/// The ResourceDescriptor Yaml config will look like:
///
/// resources:
/// - type: 'logging.googleapis.com/LogEntry'
/// name_descriptor:
/// - pattern: "projects/{project}/logs/{log}"
/// parent_type: "cloudresourcemanager.googleapis.com/Project"
/// parent_name_extractor: "projects/{project}"
/// - pattern: "folders/{folder}/logs/{log}"
/// parent_type: "cloudresourcemanager.googleapis.com/Folder"
/// parent_name_extractor: "folders/{folder}"
/// - pattern: "organizations/{organization}/logs/{log}"
/// parent_type: "cloudresourcemanager.googleapis.com/Organization"
/// parent_name_extractor: "organizations/{organization}"
/// - pattern: "billingAccounts/{billing_account}/logs/{log}"
/// parent_type: "billing.googleapis.com/BillingAccount"
/// parent_name_extractor: "billingAccounts/{billing_account}"
///
/// For flexible resources, the resource name doesn't contain parent names, but
/// the resource itself has parents for policy evaluation.
///
/// Example:
///
/// message Shelf {
/// option (google.api.resource) = {
/// type: "library.googleapis.com/Shelf"
/// name_descriptor: {
/// pattern: "shelves/{shelf}"
/// parent_type: "cloudresourcemanager.googleapis.com/Project"
/// }
/// name_descriptor: {
/// pattern: "shelves/{shelf}"
/// parent_type: "cloudresourcemanager.googleapis.com/Folder"
/// }
/// };
/// }
///
/// The ResourceDescriptor Yaml config will look like:
///
/// resources:
/// - type: 'library.googleapis.com/Shelf'
/// name_descriptor:
/// - pattern: "shelves/{shelf}"
/// parent_type: "cloudresourcemanager.googleapis.com/Project"
/// - pattern: "shelves/{shelf}"
/// parent_type: "cloudresourcemanager.googleapis.com/Folder"
/// pattern: "projects/{project}/logs/{log}"
/// pattern: "folders/{folder}/logs/{log}"
/// pattern: "organizations/{organization}/logs/{log}"
/// pattern: "billingAccounts/{billing_account}/logs/{log}"
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceDescriptor {
/// The resource type. It must be in the format of
Expand All @@ -521,7 +460,7 @@ pub struct ResourceDescriptor {
/// Example: `storage.googleapis.com/Bucket`
///
/// The value of the resource_type_kind must follow the regular expression
/// /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and
/// /\[A-Za-z][a-zA-Z0-9\]+/. It should start with an upper case character and
/// should use PascalCase (UpperCamelCase). The maximum number of
/// characters allowed for the `resource_type_kind` is 100.
#[prost(string, tag = "1")]
Expand Down Expand Up @@ -572,14 +511,14 @@ pub struct ResourceDescriptor {
/// 'projects' for the resource name of 'projects/{project}' and the permission
/// name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same
/// concept of the `plural` field in k8s CRD spec
/// https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
/// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
///
/// Note: The plural form is required even for singleton resources. See
/// https://aip.dev/156
/// <https://aip.dev/156>
#[prost(string, tag = "5")]
pub plural: ::prost::alloc::string::String,
/// The same concept of the `singular` field in k8s CRD spec
/// https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
/// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
/// Such as "project" for the `resourcemanager.googleapis.com/Project` type.
#[prost(string, tag = "6")]
pub singular: ::prost::alloc::string::String,
Expand Down

0 comments on commit aa3cb53

Please sign in to comment.