diff --git a/bigtable_rs/Cargo.toml b/bigtable_rs/Cargo.toml index 522e16c..8878399 100644 --- a/bigtable_rs/Cargo.toml +++ b/bigtable_rs/Cargo.toml @@ -13,14 +13,15 @@ readme = "../README.md" [dependencies] # tonic, prost, and prost-types are need for build generated rs files -http = "0.2.11" +http = "1.1.0" +hyper-util = { version = "0.1.7", features = ["tokio"] } tokio = { version = "1.25.0", features = ["rt-multi-thread"] } -tonic = { version = "0.11.0", features = ["tls", "transport"] } +tonic = { version = "0.12.2", features = ["tls", "transport"] } tower = { version = "0.4" } -prost = "0.12.2" -prost-types = "0.12.2" -prost-wkt = "0.5.0" -prost-wkt-types = "0.5.0" +prost = "0.13.1" +prost-types = "0.13.1" +prost-wkt = { version = "0.6.0" } +prost-wkt-types = { version = "0.6.0" } serde = { version = "1.0.192", features = ["derive"] } serde_with = { version = "3.4.0", features = ["base64"] } # end of above part @@ -34,6 +35,6 @@ serde_json = "1.0.85" serde_path_to_error = "0.1.8" [build-dependencies] -tonic-build = { version = "0.11.0", features = ["cleanup-markdown"] } -prost-build = "0.12.2" -prost-wkt-build = "0.5.0" +tonic-build = { version = "0.12.2", features = ["cleanup-markdown"] } +prost-build = "0.13.1" +prost-wkt-build = { version = "0.6.0" } diff --git a/bigtable_rs/build.rs b/bigtable_rs/build.rs index c250e52..afef08c 100644 --- a/bigtable_rs/build.rs +++ b/bigtable_rs/build.rs @@ -3,89 +3,87 @@ /// https://github.com/hyperium/tonic/tree/master/tonic-build /// https://github.com/tokio-rs/prost/issues/672 fn main() -> Result<(), Box> { - // Uncomment the code below and cargo build again, when updating google protos + use prost_wkt_build::{FileDescriptorSet, Message}; + use std::{env, path::PathBuf}; + let out = PathBuf::from(env::var("OUT_DIR").unwrap()); + let descriptor_file = out.join("descriptors.bin"); - // use prost_wkt_build::{FileDescriptorSet, Message}; - // use std::{env, path::PathBuf}; - // let out = PathBuf::from(env::var("OUT_DIR").unwrap()); - // let descriptor_file = out.join("descriptors.bin"); - // - // tonic_build::configure() - // .build_server(false) - // .out_dir("src/google") - // .compile_well_known_types(true) - // .type_attribute(".", "#[serde_with::serde_as]") - // .type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]") - // .type_attribute(".", "#[serde(rename_all = \"camelCase\")]") - // .type_attribute( - // ".google.cloud.conformance.bigtable.v2.ReadRowsTest", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.row_key", - // "#[serde_as(as = \"serde_with::base64::Base64\")]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.row_key", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.qualifier", - // "#[serde_as(as = \"Option\")]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.qualifier", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.value", - // "#[serde_as(as = \"serde_with::base64::Base64\")]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.timestamp_micros", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.labels", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.value", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.timestamp_micros", - // "#[serde_as(as = \"serde_with::DisplayFromStr\")]", - // ) - // .field_attribute( - // ".google.bigtable.v2.ReadRowsResponse.CellChunk.value_size", - // "#[serde(default)]", - // ) - // .field_attribute( - // ".google.cloud.conformance.bigtable.v2.ReadRowsTest.Result.timestamp_micros", - // "#[serde_as(as = \"serde_with::DisplayFromStr\")]", - // ) - // .extern_path( - // ".google.protobuf.BytesValue", - // "::prost::alloc::vec::Vec", - // ) - // .extern_path( - // ".google.protobuf.StringValue", - // "::prost::alloc::string::String", - // ) - // .extern_path(".google.protobuf", "::prost_wkt_types") - // .file_descriptor_set_path(&descriptor_file) - // .compile( - // &[ - // "../googleapis/google/bigtable/v2/bigtable.proto", - // "../googleapis/test/bigtable_test.proto", // only works with fork https://github.com/liufuyang/googleapis - // ], - // &["../googleapis"], - // )?; - // - // let descriptor_bytes = std::fs::read(descriptor_file).unwrap(); - // let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..]).unwrap(); - // prost_wkt_build::add_serde(out, descriptor); + tonic_build::configure() + .build_server(false) + .out_dir("src/google") + .compile_well_known_types(true) + .type_attribute(".", "#[serde_with::serde_as]") + .type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]") + .type_attribute(".", "#[serde(rename_all = \"camelCase\")]") + .type_attribute( + ".google.cloud.conformance.bigtable.v2.ReadRowsTest", + "#[serde(default)]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.row_key", + "#[serde_as(as = \"serde_with::base64::Base64\")]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.row_key", + "#[serde(default)]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.qualifier", + "#[serde_as(as = \"Option\")]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.qualifier", + "#[serde(default)]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.value", + "#[serde_as(as = \"serde_with::base64::Base64\")]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.timestamp_micros", + "#[serde(default)]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.labels", + "#[serde(default)]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.value", + "#[serde(default)]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.timestamp_micros", + "#[serde_as(as = \"serde_with::DisplayFromStr\")]", + ) + .field_attribute( + ".google.bigtable.v2.ReadRowsResponse.CellChunk.value_size", + "#[serde(default)]", + ) + .field_attribute( + ".google.cloud.conformance.bigtable.v2.ReadRowsTest.Result.timestamp_micros", + "#[serde_as(as = \"serde_with::DisplayFromStr\")]", + ) + .extern_path( + ".google.protobuf.BytesValue", + "::prost::alloc::vec::Vec", + ) + .extern_path( + ".google.protobuf.StringValue", + "::prost::alloc::string::String", + ) + .extern_path(".google.protobuf", "::prost_wkt_types") + .file_descriptor_set_path(&descriptor_file) + .compile( + &[ + "../googleapis/google/bigtable/v2/bigtable.proto", + "../googleapis/test/bigtable_test.proto", // only works with fork https://github.com/liufuyang/googleapis + ], + &["../googleapis"], + )?; + + let descriptor_bytes = std::fs::read(descriptor_file).unwrap(); + let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..]).unwrap(); + prost_wkt_build::add_serde(out, descriptor); Ok(()) } diff --git a/bigtable_rs/src/auth_service.rs b/bigtable_rs/src/auth_service.rs index 96fc505..4104949 100644 --- a/bigtable_rs/src/auth_service.rs +++ b/bigtable_rs/src/auth_service.rs @@ -7,7 +7,6 @@ use gcp_auth::TokenProvider; use http::{HeaderValue, Request, Response}; use log::debug; use tonic::body::BoxBody; -use tonic::transport::Body; use tonic::transport::Channel; use tower::Service; @@ -33,7 +32,7 @@ impl AuthSvc { } impl Service> for AuthSvc { - type Response = Response; + type Response = Response; type Error = Box; #[allow(clippy::type_complexity)] type Future = Pin> + Send>>; diff --git a/bigtable_rs/src/bigtable.rs b/bigtable_rs/src/bigtable.rs index 2fdce6e..9fc12ea 100644 --- a/bigtable_rs/src/bigtable.rs +++ b/bigtable_rs/src/bigtable.rs @@ -364,7 +364,13 @@ impl BigTableConnection { let path: String = path.to_string(); let connector = tower::service_fn({ - move |_: tonic::transport::Uri| UnixStream::connect(path.clone()) + move |_: tonic::transport::Uri| { + let path = path.clone(); + async move { + let stream = UnixStream::connect(path).await?; + Ok::<_, std::io::Error>(hyper_util::rt::TokioIo::new(stream)) + } + } }); endpoint.connect_with_connector_lazy(connector) diff --git a/bigtable_rs/src/google/google.api.rs b/bigtable_rs/src/google/google.api.rs index c22f386..33cb6c3 100644 --- a/bigtable_rs/src/google/google.api.rs +++ b/bigtable_rs/src/google/google.api.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// 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 /// to one or more HTTP REST API methods. @@ -782,7 +783,7 @@ pub mod method_settings { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] + #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LongRunning { /// Initial delay after which the first poll request will be made. /// Default value: 5 seconds. diff --git a/bigtable_rs/src/google/google.bigtable.v2.rs b/bigtable_rs/src/google/google.bigtable.v2.rs index 6085827..1df9a71 100644 --- a/bigtable_rs/src/google/google.bigtable.v2.rs +++ b/bigtable_rs/src/google/google.bigtable.v2.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// Specifies the complete (requested) contents of a single row of a table. /// Rows which exceed 256MiB in size cannot be read in full. #[serde_with::serde_as] @@ -202,7 +203,7 @@ pub mod column_range { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct TimestampRange { /// Inclusive lower bound. If left empty, interpreted as 0. #[prost(int64, tag = "1")] @@ -637,7 +638,7 @@ pub mod mutation { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] + #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct DeleteFromRow {} /// Which of the possible Mutation types to apply. #[serde_with::serde_as] @@ -754,7 +755,7 @@ pub struct StreamContinuationToken { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ReadIterationStats { /// The rows seen (scanned) as part of the request. This includes the count of /// rows returned, as captured below. @@ -778,7 +779,7 @@ pub struct ReadIterationStats { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct RequestLatencyStats { /// The latency measured by the frontend server handling this request, from /// when the request was received, to when this value is sent back in the @@ -805,7 +806,7 @@ pub struct RequestLatencyStats { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct FullReadStatsView { /// Iteration stats describe how efficient the read is, e.g. comparing /// rows seen vs. rows returned or cells seen vs cells returned can provide an @@ -827,7 +828,7 @@ pub struct FullReadStatsView { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct RequestStats { /// Information pertaining to each request type received. The type is chosen /// based on the requested view. @@ -846,7 +847,7 @@ pub mod request_stats { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum StatsView { /// Available with the ReadRowsRequest.RequestStatsView.REQUEST_STATS_FULL /// view, see package google.bigtable.v2. @@ -1067,7 +1068,7 @@ pub mod read_rows_response { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum RowStatus { /// Indicates that the client should drop all previous chunks for /// `row_key`, as it will be re-read from the beginning. @@ -1150,7 +1151,7 @@ pub struct MutateRowRequest { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct MutateRowResponse {} /// Request message for BigtableService.MutateRows. #[serde_with::serde_as] @@ -1236,7 +1237,7 @@ pub mod mutate_rows_response { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct RateLimitInfo { /// Time that clients should wait before adjusting the target rate again. /// If clients adjust rate too frequently, the impact of the previous @@ -1304,7 +1305,7 @@ pub struct CheckAndMutateRowRequest { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CheckAndMutateRowResponse { /// Whether or not the request's `predicate_filter` yielded any results for /// the specified row. @@ -1333,7 +1334,7 @@ pub struct PingAndWarmRequest { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct PingAndWarmResponse {} /// Request message for Bigtable.ReadModifyWriteRow. #[serde_with::serde_as] @@ -1508,7 +1509,7 @@ pub mod read_change_stream_response { #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] + #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ChunkInfo { /// The total value size of all the chunks that make up the `SetCell`. #[prost(int32, tag = "1")] @@ -1729,8 +1730,8 @@ pub mod bigtable_client { where T: tonic::client::GrpcService, T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, + 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); @@ -1754,7 +1755,7 @@ pub mod bigtable_client { >, >, >>::Error: - Into + Send + Sync, + Into + std::marker::Send + std::marker::Sync, { BigtableClient::new(InterceptedService::new(inner, interceptor)) } diff --git a/bigtable_rs/src/google/google.cloud.conformance.bigtable.v2.rs b/bigtable_rs/src/google/google.cloud.conformance.bigtable.v2.rs index 2e2b055..5728d67 100644 --- a/bigtable_rs/src/google/google.cloud.conformance.bigtable.v2.rs +++ b/bigtable_rs/src/google/google.cloud.conformance.bigtable.v2.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[serde_with::serde_as] #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/bigtable_rs/src/google/google.rpc.rs b/bigtable_rs/src/google/google.rpc.rs index c683800..a3681bf 100644 --- a/bigtable_rs/src/google/google.rpc.rs +++ b/bigtable_rs/src/google/google.rpc.rs @@ -1,3 +1,4 @@ +// 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