Skip to content

Commit

Permalink
chore: update to http 1.x crates
Browse files Browse the repository at this point in the history
This requires updating prost crates to 0.13.x, tonic to 0.12.x and
prost-wkt-* to 0.6.*.

Only the examples still pull in http 0.x, due to
seanmonstar/warp#1090, but that shouldn't affect
consumers of bigtable_rs.

Co-Authored-By: Connor Brewster <cbrewster@hey.com>
  • Loading branch information
2 people authored and liufuyang committed Sep 9, 2024
1 parent 9de9da7 commit 79af8eb
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 111 deletions.
19 changes: 10 additions & 9 deletions bigtable_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" }
162 changes: 80 additions & 82 deletions bigtable_rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>> {
// 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<serde_with::base64::Base64>\")]",
// )
// .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<u8>",
// )
// .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<serde_with::base64::Base64>\")]",
)
.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<u8>",
)
.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(())
}
3 changes: 1 addition & 2 deletions bigtable_rs/src/auth_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -33,7 +32,7 @@ impl AuthSvc {
}

impl Service<Request<BoxBody>> for AuthSvc {
type Response = Response<Body>;
type Response = Response<BoxBody>;
type Error = Box<dyn std::error::Error + Send + Sync>;
#[allow(clippy::type_complexity)]
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
Expand Down
8 changes: 7 additions & 1 deletion bigtable_rs/src/bigtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion bigtable_rs/src/google/google.api.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.

Check notice on line 1 in bigtable_rs/src/google/google.api.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

File: bigtable_rs/src/google/google.api.rs
/// 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.
Expand Down Expand Up @@ -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.
Expand Down
33 changes: 17 additions & 16 deletions bigtable_rs/src/google/google.bigtable.v2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.

Check notice on line 1 in bigtable_rs/src/google/google.bigtable.v2.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

File: bigtable_rs/src/google/google.bigtable.v2.rs
/// 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]
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -1729,8 +1730,8 @@ pub mod bigtable_client {
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Expand All @@ -1754,7 +1755,7 @@ pub mod bigtable_client {
>,
>,
<T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error:
Into<StdError> + Send + Sync,
Into<StdError> + std::marker::Send + std::marker::Sync,
{
BigtableClient::new(InterceptedService::new(inner, interceptor))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.

Check notice on line 1 in bigtable_rs/src/google/google.cloud.conformance.bigtable.v2.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

File: bigtable_rs/src/google/google.cloud.conformance.bigtable.v2.rs
#[serde_with::serde_as]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
1 change: 1 addition & 0 deletions bigtable_rs/src/google/google.rpc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is @generated by prost-build.

Check notice on line 1 in bigtable_rs/src/google/google.rpc.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

File: bigtable_rs/src/google/google.rpc.rs
/// 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](<https://github.com/grpc>). Each `Status` message contains
Expand Down

0 comments on commit 79af8eb

Please sign in to comment.