From 6f9bda577303d26ee7c5343ed483e6d67e74f22e Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Tue, 23 Jul 2024 12:09:39 +0200 Subject: [PATCH 1/5] Rename tonic into tonic_0_10 to prepare for bumping it to 0.12 --- Cargo.toml | 8 +++--- crates/admin/Cargo.toml | 4 +-- crates/admin/build.rs | 2 +- .../admin/src/cluster_controller/protobuf.rs | 4 +-- crates/admin/src/lib.rs | 1 + crates/admin/src/service.rs | 2 +- crates/admin/src/state.rs | 2 +- crates/admin/src/storage_query/error.rs | 2 +- crates/core/Cargo.toml | 4 +-- crates/core/build.rs | 2 +- crates/core/src/lib.rs | 2 ++ crates/core/src/network/connection_manager.rs | 4 +-- crates/core/src/network/error.rs | 28 +++++++++---------- crates/core/src/network/grpc_util.rs | 2 +- crates/core/src/network/protobuf.rs | 4 +-- crates/metadata-store/Cargo.toml | 8 +++--- crates/metadata-store/build.rs | 2 +- crates/metadata-store/src/grpc_svc.rs | 5 ++-- crates/metadata-store/src/lib.rs | 2 ++ .../metadata-store/src/local/grpc/client.rs | 4 +-- .../metadata-store/src/local/grpc/handler.rs | 2 +- crates/metadata-store/src/local/service.rs | 8 +++--- crates/metadata-store/src/local/tests.rs | 4 +-- crates/node/Cargo.toml | 4 +-- .../network_server/handler/cluster_ctrl.rs | 4 +-- .../node/src/network_server/handler/node.rs | 2 +- crates/node/src/network_server/service.rs | 6 ++-- crates/node/src/roles/admin.rs | 2 +- crates/node/src/roles/worker.rs | 2 +- tools/restatectl/Cargo.toml | 2 +- .../src/commands/dump/cluster_state.rs | 2 +- tools/restatectl/src/util.rs | 6 ++-- tools/xtask/Cargo.toml | 2 +- tools/xtask/src/main.rs | 2 +- 34 files changed, 74 insertions(+), 66 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf6e96268..7baf30b41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,10 +152,10 @@ thiserror = "1.0" tokio = { version = "1.29", default-features = false, features = ["rt-multi-thread", "signal", "macros", ] } tokio-stream = "0.1.14" tokio-util = { version = "0.7.10" } -tonic = { version = "0.10.2", default-features = false } -tonic-reflection = { version = "0.10.2" } -tonic-health = "0.10.2" -tonic-build = "0.11.0" +tonic-0-10 = { package = "tonic", version = "0.10.2", default-features = false } +tonic-reflection-0-10 = { package = "tonic-reflection", version = "0.10.2" } +tonic-health-0-10 = { package = "tonic-health", version = "0.10.2" } +tonic-build-0-11 = { package = "tonic-build", version = "0.11.0" } tower = "0.4" tower-http = { version = "0.5.2", default-features = false } tracing = "0.1" diff --git a/crates/admin/Cargo.toml b/crates/admin/Cargo.toml index 722586156..6da4259fc 100644 --- a/crates/admin/Cargo.toml +++ b/crates/admin/Cargo.toml @@ -50,12 +50,12 @@ serde_json = { workspace = true } serde_with = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } -tonic = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } +tonic-0-10 = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } tower = { workspace = true, features = ["load-shed", "limit"] } tracing = { workspace = true } [build-dependencies] -tonic-build = { workspace = true } +tonic-build-0-11 = { workspace = true } [dev-dependencies] restate-bifrost = { workspace = true, features = ["test-util"] } diff --git a/crates/admin/build.rs b/crates/admin/build.rs index 16702231e..5f71248af 100644 --- a/crates/admin/build.rs +++ b/crates/admin/build.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - tonic_build::configure() + tonic_build_0_11::configure() .bytes(["."]) .file_descriptor_set_path(out_dir.join("cluster_ctrl_svc_descriptor.bin")) .server_mod_attribute("cluster_ctrl", "#[cfg(feature = \"servers\")]") diff --git a/crates/admin/src/cluster_controller/protobuf.rs b/crates/admin/src/cluster_controller/protobuf.rs index 8d5274e78..cc917517d 100644 --- a/crates/admin/src/cluster_controller/protobuf.rs +++ b/crates/admin/src/cluster_controller/protobuf.rs @@ -8,7 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -tonic::include_proto!("restate.cluster_ctrl"); +tonic_0_10::include_proto!("restate.cluster_ctrl"); pub const FILE_DESCRIPTOR_SET: &[u8] = - tonic::include_file_descriptor_set!("cluster_ctrl_svc_descriptor"); + tonic_0_10::include_file_descriptor_set!("cluster_ctrl_svc_descriptor"); diff --git a/crates/admin/src/lib.rs b/crates/admin/src/lib.rs index 1ba4442ed..54c18b27f 100644 --- a/crates/admin/src/lib.rs +++ b/crates/admin/src/lib.rs @@ -8,6 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate tonic_0_10 as tonic; pub mod cluster_controller; mod error; mod rest_api; diff --git a/crates/admin/src/service.rs b/crates/admin/src/service.rs index c44bf6ca7..f0f50eeab 100644 --- a/crates/admin/src/service.rs +++ b/crates/admin/src/service.rs @@ -15,7 +15,7 @@ use http::StatusCode; use restate_bifrost::Bifrost; use restate_types::config::AdminOptions; use restate_types::live::LiveLoad; -use tonic::transport::Channel; +use tonic_0_10::transport::Channel; use tower::ServiceBuilder; use tracing::info; diff --git a/crates/admin/src/state.rs b/crates/admin/src/state.rs index 46df7ab18..cb28e6f00 100644 --- a/crates/admin/src/state.rs +++ b/crates/admin/src/state.rs @@ -13,7 +13,7 @@ use crate::schema_registry::SchemaRegistry; use restate_bifrost::Bifrost; use restate_core::network::protobuf::node_svc::node_svc_client::NodeSvcClient; use restate_core::TaskCenter; -use tonic::transport::Channel; +use tonic_0_10::transport::Channel; #[derive(Clone, derive_builder::Builder)] pub struct AdminServiceState { diff --git a/crates/admin/src/storage_query/error.rs b/crates/admin/src/storage_query/error.rs index 3ce25b690..53e59544c 100644 --- a/crates/admin/src/storage_query/error.rs +++ b/crates/admin/src/storage_query/error.rs @@ -24,7 +24,7 @@ use serde::Serialize; #[derive(Debug, thiserror::Error)] pub enum StorageQueryError { #[error("failed grpc: {0}")] - Tonic(#[from] tonic::Status), + Tonic(#[from] tonic_0_10::Status), } /// # Error description response diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 39efc8b10..4a8b77d0d 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -47,12 +47,12 @@ thiserror = { workspace = true } tokio = { workspace = true, features = ["tracing"] } tokio-stream = { workspace = true, features = ["net"] } tokio-util = { workspace = true } -tonic = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } +tonic-0-10 = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } tower = { workspace = true } tracing = { workspace = true } [build-dependencies] -tonic-build = { workspace = true } +tonic-build-0-11 = { workspace = true } [dev-dependencies] restate-test-util = { workspace = true } diff --git a/crates/core/build.rs b/crates/core/build.rs index abf617581..100ae60a0 100644 --- a/crates/core/build.rs +++ b/crates/core/build.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - tonic_build::configure() + tonic_build_0_11::configure() .bytes(["."]) .file_descriptor_set_path(out_dir.join("node_svc_descriptor.bin")) // allow older protobuf compiler to be used diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 7e443aa1c..8f8970770 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -8,6 +8,8 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate tonic_0_10 as tonic; + mod metadata; pub mod metadata_store; mod metric_definitions; diff --git a/crates/core/src/network/connection_manager.rs b/crates/core/src/network/connection_manager.rs index 9aa58d447..c198ebab9 100644 --- a/crates/core/src/network/connection_manager.rs +++ b/crates/core/src/network/connection_manager.rs @@ -18,7 +18,7 @@ use rand::seq::SliceRandom; use restate_types::net::codec::try_unwrap_binary_message; use tokio::sync::mpsc; use tokio_stream::wrappers::ReceiverStream; -use tonic::transport::Channel; +use tonic_0_10::transport::Channel; use tracing::{debug, info, trace, warn, Instrument, Span}; use restate_types::live::Pinned; @@ -112,7 +112,7 @@ impl ConnectionManager { pub async fn accept_incoming_connection( &self, mut incoming: S, - ) -> Result>, NetworkError> + ) -> Result>, NetworkError> where S: Stream> + Unpin + Send + 'static, { diff --git a/crates/core/src/network/error.rs b/crates/core/src/network/error.rs index 65c242036..99b676dd9 100644 --- a/crates/core/src/network/error.rs +++ b/crates/core/src/network/error.rs @@ -34,8 +34,8 @@ pub enum NetworkError { Timeout(&'static str), #[error("protocol error: {0}")] ProtocolError(#[from] ProtocolError), - #[error("cannot connect: {} {}", tonic::Status::code(.0), tonic::Status::message(.0))] - ConnectError(#[from] tonic::Status), + #[error("cannot connect: {} {}", tonic_0_10::Status::code(.0), tonic_0_10::Status::message(.0))] + ConnectError(#[from] tonic_0_10::Status), #[error("new node generation exists: {0}")] OldPeerGeneration(String), #[error("peer is not connected")] @@ -57,7 +57,7 @@ pub enum ProtocolError { #[error("codec error: {0}")] Codec(#[from] CodecError), #[error("grpc error: {0}")] - GrpcError(#[from] tonic::Status), + GrpcError(#[from] tonic_0_10::Status), #[error( "peer has unsupported protocol version {0}, minimum supported is '{}'", MIN_SUPPORTED_PROTOCOL_VERSION as i32 @@ -65,30 +65,30 @@ pub enum ProtocolError { UnsupportedVersion(i32), } -impl From for tonic::Status { +impl From for tonic_0_10::Status { fn from(value: ProtocolError) -> Self { match value { - ProtocolError::HandshakeFailed(e) => tonic::Status::invalid_argument(e), - ProtocolError::HandshakeTimeout(e) => tonic::Status::deadline_exceeded(e), - ProtocolError::PeerDropped => tonic::Status::cancelled("peer dropped"), - ProtocolError::Codec(e) => tonic::Status::internal(e.to_string()), + ProtocolError::HandshakeFailed(e) => tonic_0_10::Status::invalid_argument(e), + ProtocolError::HandshakeTimeout(e) => tonic_0_10::Status::deadline_exceeded(e), + ProtocolError::PeerDropped => tonic_0_10::Status::cancelled("peer dropped"), + ProtocolError::Codec(e) => tonic_0_10::Status::internal(e.to_string()), ProtocolError::UnsupportedVersion(_) => { - tonic::Status::invalid_argument(value.to_string()) + tonic_0_10::Status::invalid_argument(value.to_string()) } ProtocolError::GrpcError(s) => s, } } } -impl From for tonic::Status { +impl From for tonic_0_10::Status { fn from(value: NetworkError) -> Self { match value { - NetworkError::Shutdown(_) => tonic::Status::unavailable(value.to_string()), + NetworkError::Shutdown(_) => tonic_0_10::Status::unavailable(value.to_string()), NetworkError::ProtocolError(e) => e.into(), - NetworkError::Timeout(e) => tonic::Status::deadline_exceeded(e), - NetworkError::OldPeerGeneration(e) => tonic::Status::already_exists(e), + NetworkError::Timeout(e) => tonic_0_10::Status::deadline_exceeded(e), + NetworkError::OldPeerGeneration(e) => tonic_0_10::Status::already_exists(e), NetworkError::ConnectError(s) => s, - e => tonic::Status::internal(e.to_string()), + e => tonic_0_10::Status::internal(e.to_string()), } } } diff --git a/crates/core/src/network/grpc_util.rs b/crates/core/src/network/grpc_util.rs index 9fad55568..472f7c648 100644 --- a/crates/core/src/network/grpc_util.rs +++ b/crates/core/src/network/grpc_util.rs @@ -22,7 +22,7 @@ use tokio::io; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::{UnixListener, UnixStream}; use tokio_stream::wrappers::UnixListenerStream; -use tonic::transport::{Channel, Endpoint}; +use tonic_0_10::transport::{Channel, Endpoint}; use tracing::{debug, info}; pub fn create_grpc_channel_from_advertised_address( diff --git a/crates/core/src/network/protobuf.rs b/crates/core/src/network/protobuf.rs index 458a5558e..174d691b1 100644 --- a/crates/core/src/network/protobuf.rs +++ b/crates/core/src/network/protobuf.rs @@ -9,8 +9,8 @@ // by the Apache License, Version 2.0. pub mod node_svc { - tonic::include_proto!("restate.node_svc"); + tonic_0_10::include_proto!("restate.node_svc"); pub const FILE_DESCRIPTOR_SET: &[u8] = - tonic::include_file_descriptor_set!("node_svc_descriptor"); + tonic_0_10::include_file_descriptor_set!("node_svc_descriptor"); } diff --git a/crates/metadata-store/Cargo.toml b/crates/metadata-store/Cargo.toml index 9b300f277..ee827f968 100644 --- a/crates/metadata-store/Cargo.toml +++ b/crates/metadata-store/Cargo.toml @@ -32,9 +32,9 @@ serde = { workspace = true } static_assertions = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } -tonic = { workspace = true, features = ["transport", "codegen", "prost"] } -tonic-reflection = { workspace = true } -tonic-health = { workspace = true } +tonic-0-10 = { workspace = true, features = ["transport", "codegen", "prost"] } +tonic-reflection-0-10 = { workspace = true } +tonic-health-0-10 = { workspace = true } tower = { workspace = true } tower-http-0-4 = { package = "tower-http", version = "0.4", features = ["trace"] } tracing = { workspace = true } @@ -51,4 +51,4 @@ test-log = { workspace = true } tracing-subscriber = { workspace = true } [build-dependencies] -tonic-build = { workspace = true } +tonic-build-0-11 = { workspace = true } diff --git a/crates/metadata-store/build.rs b/crates/metadata-store/build.rs index b2b100490..de0038e83 100644 --- a/crates/metadata-store/build.rs +++ b/crates/metadata-store/build.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - tonic_build::configure() + tonic_build_0_11::configure() .bytes(["."]) .file_descriptor_set_path(out_dir.join("metadata_store_svc.bin")) // allow older protobuf compiler to be used diff --git a/crates/metadata-store/src/grpc_svc.rs b/crates/metadata-store/src/grpc_svc.rs index 0b4034460..61c698800 100644 --- a/crates/metadata-store/src/grpc_svc.rs +++ b/crates/metadata-store/src/grpc_svc.rs @@ -8,6 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -tonic::include_proto!("dev.restate.metadata_store_svc"); +tonic_0_10::include_proto!("dev.restate.metadata_store_svc"); -pub const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("metadata_store_svc"); +pub const FILE_DESCRIPTOR_SET: &[u8] = + tonic_0_10::include_file_descriptor_set!("metadata_store_svc"); diff --git a/crates/metadata-store/src/lib.rs b/crates/metadata-store/src/lib.rs index 198840cc9..583e0832e 100644 --- a/crates/metadata-store/src/lib.rs +++ b/crates/metadata-store/src/lib.rs @@ -8,6 +8,8 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate tonic_0_10 as tonic; + mod grpc_svc; pub mod local; diff --git a/crates/metadata-store/src/local/grpc/client.rs b/crates/metadata-store/src/local/grpc/client.rs index baf7146af..2732fa7af 100644 --- a/crates/metadata-store/src/local/grpc/client.rs +++ b/crates/metadata-store/src/local/grpc/client.rs @@ -10,8 +10,8 @@ use async_trait::async_trait; use bytestring::ByteString; -use tonic::transport::Channel; -use tonic::{Code, Status}; +use tonic_0_10::transport::Channel; +use tonic_0_10::{Code, Status}; use restate_core::metadata_store::{ MetadataStore, Precondition, ReadError, VersionedValue, WriteError, diff --git a/crates/metadata-store/src/local/grpc/handler.rs b/crates/metadata-store/src/local/grpc/handler.rs index 79d948ddd..e9faafd44 100644 --- a/crates/metadata-store/src/local/grpc/handler.rs +++ b/crates/metadata-store/src/local/grpc/handler.rs @@ -14,7 +14,7 @@ use crate::local::grpc::pb_conversions::ConversionError; use crate::local::store::{Error, MetadataStoreRequest, RequestSender}; use async_trait::async_trait; use tokio::sync::oneshot; -use tonic::{Request, Response, Status}; +use tonic_0_10::{Request, Response, Status}; /// Grpc svc handler for the [`LocalMetadataStore`]. #[derive(Debug)] diff --git a/crates/metadata-store/src/local/service.rs b/crates/metadata-store/src/local/service.rs index 8047f77c7..935bc3e0f 100644 --- a/crates/metadata-store/src/local/service.rs +++ b/crates/metadata-store/src/local/service.rs @@ -8,7 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use tonic::server::NamedService; +use tonic_0_10::server::NamedService; use restate_core::network::grpc_util; use restate_core::{cancellation_watcher, task_center, ShutdownError, TaskKind}; @@ -31,7 +31,7 @@ pub enum Error { #[error("failed running grpc server: {0}")] GrpcServer(#[from] grpc_util::Error), #[error("error while running server server grpc reflection service: {0}")] - GrpcReflection(#[from] tonic_reflection::server::Error), + GrpcReflection(#[from] tonic_reflection_0_10::server::Error), #[error("system is shutting down")] Shutdown(#[from] ShutdownError), #[error("rocksdb error: {0}")] @@ -66,10 +66,10 @@ impl LocalMetadataStoreService { .include_headers(true) .level(tracing::Level::ERROR); - let reflection_service_builder = tonic_reflection::server::Builder::configure() + let reflection_service_builder = tonic_reflection_0_10::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_svc::FILE_DESCRIPTOR_SET); - let (mut health_reporter, health_service) = tonic_health::server::health_reporter(); + let (mut health_reporter, health_service) = tonic_health_0_10::server::health_reporter(); health_reporter .set_serving::>() .await; diff --git a/crates/metadata-store/src/local/tests.rs b/crates/metadata-store/src/local/tests.rs index 404ffeed4..056c24a5a 100644 --- a/crates/metadata-store/src/local/tests.rs +++ b/crates/metadata-store/src/local/tests.rs @@ -15,8 +15,8 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use serde::{Deserialize, Serialize}; use test_log::test; -use tonic_health::pb::health_client::HealthClient; -use tonic_health::pb::HealthCheckRequest; +use tonic_health_0_10::pb::health_client::HealthClient; +use tonic_health_0_10::pb::HealthCheckRequest; use restate_core::network::grpc_util::create_grpc_channel_from_advertised_address; use restate_core::{MockNetworkSender, TaskCenter, TaskKind, TestCoreEnv, TestCoreEnvBuilder}; diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index 837d811fe..cb9738f51 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -64,8 +64,8 @@ thiserror = { workspace = true } tokio = { workspace = true } tokio-stream = { workspace = true } tokio-util = { workspace = true } -tonic = { workspace = true } -tonic-reflection = { workspace = true } +tonic-0-10 = { workspace = true } +tonic-reflection-0-10 = { workspace = true } tower = { workspace = true } tower-http-0-4 = { package = "tower-http", version = "0.4", features = ["trace"] } tracing = { workspace = true } diff --git a/crates/node/src/network_server/handler/cluster_ctrl.rs b/crates/node/src/network_server/handler/cluster_ctrl.rs index 70d037538..c57767543 100644 --- a/crates/node/src/network_server/handler/cluster_ctrl.rs +++ b/crates/node/src/network_server/handler/cluster_ctrl.rs @@ -8,7 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use tonic::{async_trait, Request, Response, Status}; +use tonic_0_10::{async_trait, Request, Response, Status}; use tracing::info; use restate_admin::cluster_controller::protobuf::cluster_ctrl_svc_server::ClusterCtrlSvc; @@ -45,7 +45,7 @@ impl ClusterCtrlSvc for ClusterCtrlSvcHandler { .controller_handle .get_cluster_state() .await - .map_err(|_| tonic::Status::aborted("Node is shutting down"))?; + .map_err(|_| tonic_0_10::Status::aborted("Node is shutting down"))?; let resp = ClusterStateResponse { cluster_state: Some((*cluster_state).clone().into()), diff --git a/crates/node/src/network_server/handler/node.rs b/crates/node/src/network_server/handler/node.rs index 60f693203..f8a030792 100644 --- a/crates/node/src/network_server/handler/node.rs +++ b/crates/node/src/network_server/handler/node.rs @@ -13,7 +13,7 @@ use arrow_flight::error::FlightError; use futures::stream::BoxStream; use futures::TryStreamExt; use tokio_stream::StreamExt; -use tonic::{Request, Response, Status, Streaming}; +use tonic_0_10::{Request, Response, Status, Streaming}; use restate_core::network::protobuf::node_svc::node_svc_server::NodeSvc; use restate_core::network::protobuf::node_svc::IdentResponse; diff --git a/crates/node/src/network_server/service.rs b/crates/node/src/network_server/service.rs index 829add208..ca4a3fc28 100644 --- a/crates/node/src/network_server/service.rs +++ b/crates/node/src/network_server/service.rs @@ -9,7 +9,7 @@ // by the Apache License, Version 2.0. use axum_0_6::routing::get; -use tonic::codec::CompressionEncoding; +use tonic_0_10::codec::CompressionEncoding; use tower_http_0_4::trace::TraceLayer; use restate_admin::cluster_controller::protobuf::cluster_ctrl_svc_server::ClusterCtrlSvcServer; @@ -73,7 +73,7 @@ impl NetworkServer { .fallback(handler_404); // -- GRPC Service Setup - let mut reflection_service_builder = tonic_reflection::server::Builder::configure() + let mut reflection_service_builder = tonic_reflection_0_10::server::Builder::configure() .register_encoded_file_descriptor_set( restate_core::network::protobuf::node_svc::FILE_DESCRIPTOR_SET, ) @@ -92,7 +92,7 @@ impl NetworkServer { .send_compressed(CompressionEncoding::Gzip) }); - let server_builder = tonic::transport::Server::builder() + let server_builder = tonic_0_10::transport::Server::builder() .layer(TraceLayer::new_for_grpc().make_span_with(span_factory)) .add_service( NodeSvcServer::new(NodeSvcHandler::new( diff --git a/crates/node/src/roles/admin.rs b/crates/node/src/roles/admin.rs index f600a822d..d1b7a44d1 100644 --- a/crates/node/src/roles/admin.rs +++ b/crates/node/src/roles/admin.rs @@ -13,7 +13,7 @@ use std::time::Duration; use anyhow::Context; use codederror::CodedError; use tokio::sync::oneshot; -use tonic::transport::Channel; +use tonic_0_10::transport::Channel; use restate_admin::cluster_controller::ClusterControllerHandle; use restate_admin::service::AdminService; diff --git a/crates/node/src/roles/worker.rs b/crates/node/src/roles/worker.rs index b6cf4a1c7..cb4f402a9 100644 --- a/crates/node/src/roles/worker.rs +++ b/crates/node/src/roles/worker.rs @@ -43,7 +43,7 @@ pub enum WorkerRoleError { pub enum SchemaError { #[error("failed to fetch schema updates: {0}")] #[code(unknown)] - Fetch(#[from] tonic::Status), + Fetch(#[from] tonic_0_10::Status), #[error("failed updating subscriptions: {0}")] #[code(unknown)] Subscription(#[from] restate_worker::WorkerHandleError), diff --git a/tools/restatectl/Cargo.toml b/tools/restatectl/Cargo.toml index 5a71b1b78..46d9b76f3 100644 --- a/tools/restatectl/Cargo.toml +++ b/tools/restatectl/Cargo.toml @@ -23,7 +23,7 @@ prost-types = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } tokio-stream = { workspace = true } -tonic = { workspace = true, features = ["transport", "prost"] } +tonic-0-10 = { workspace = true, features = ["transport", "prost"] } tower = { workspace = true } tracing = { workspace = true } tracing-log = { version = "0.2" } diff --git a/tools/restatectl/src/commands/dump/cluster_state.rs b/tools/restatectl/src/commands/dump/cluster_state.rs index 391bff989..642aadebb 100644 --- a/tools/restatectl/src/commands/dump/cluster_state.rs +++ b/tools/restatectl/src/commands/dump/cluster_state.rs @@ -26,7 +26,7 @@ use restate_types::protobuf::cluster::{ node_state, DeadNode, PartitionProcessorStatus, ReplayStatus, RunMode, }; use restate_types::{GenerationalNodeId, PlainNodeId}; -use tonic::codec::CompressionEncoding; +use tonic_0_10::codec::CompressionEncoding; use crate::app::ConnectionInfo; use crate::util::grpc_connect; diff --git a/tools/restatectl/src/util.rs b/tools/restatectl/src/util.rs index 0d9c11622..7c5fd35d8 100644 --- a/tools/restatectl/src/util.rs +++ b/tools/restatectl/src/util.rs @@ -11,10 +11,12 @@ use restate_cli_util::CliContext; use restate_types::net::AdvertisedAddress; use tokio::net::UnixStream; -use tonic::transport::{Channel, Endpoint, Uri}; +use tonic_0_10::transport::{Channel, Endpoint, Uri}; use tower::service_fn; -pub async fn grpc_connect(address: AdvertisedAddress) -> Result { +pub async fn grpc_connect( + address: AdvertisedAddress, +) -> Result { let ctx = CliContext::get(); match address { AdvertisedAddress::Uds(uds_path) => { diff --git a/tools/xtask/Cargo.toml b/tools/xtask/Cargo.toml index 0c1775e0e..bdeefde56 100644 --- a/tools/xtask/Cargo.toml +++ b/tools/xtask/Cargo.toml @@ -23,4 +23,4 @@ reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tl schemars = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } -tonic = { workspace = true } +tonic-0-10 = { workspace = true } diff --git a/tools/xtask/src/main.rs b/tools/xtask/src/main.rs index e3cf390d3..efb8b59d6 100644 --- a/tools/xtask/src/main.rs +++ b/tools/xtask/src/main.rs @@ -15,7 +15,7 @@ use std::{env, io}; use anyhow::bail; use reqwest::header::ACCEPT; use schemars::gen::SchemaSettings; -use tonic::transport::{Channel, Uri}; +use tonic_0_10::transport::{Channel, Uri}; use restate_admin::service::AdminService; use restate_bifrost::Bifrost; From f6dfafd12ef675153b647c7d41cc9664ca4d95f0 Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Tue, 23 Jul 2024 12:44:06 +0200 Subject: [PATCH 2/5] Rename prost dependencies to prost-0-12 to prepare for bumping to 0.13.1 --- Cargo.toml | 6 +++--- crates/admin/Cargo.toml | 4 ++-- crates/admin/src/lib.rs | 2 ++ crates/core/Cargo.toml | 4 ++-- crates/core/src/lib.rs | 2 ++ crates/invoker-impl/Cargo.toml | 2 +- crates/metadata-store/Cargo.toml | 4 ++-- crates/metadata-store/src/lib.rs | 2 ++ crates/node/Cargo.toml | 2 +- crates/partition-store/Cargo.toml | 2 +- crates/partition-store/src/keys.rs | 6 +++--- crates/serde-util/Cargo.toml | 4 ++-- crates/serde-util/src/proto.rs | 4 ++-- crates/service-protocol/Cargo.toml | 2 +- crates/service-protocol/src/codec.rs | 4 ++-- crates/service-protocol/src/lib.rs | 2 ++ crates/service-protocol/src/message/encoding.rs | 8 ++++---- crates/service-protocol/src/message/mod.rs | 2 +- crates/storage-api/Cargo.toml | 6 +++--- crates/storage-api/build.rs | 2 +- crates/storage-api/src/lib.rs | 3 +++ crates/storage-api/src/storage.rs | 2 +- crates/storage-query-datafusion/Cargo.toml | 2 +- crates/storage-query-datafusion/src/journal/tests.rs | 2 +- crates/storage-query-postgres/Cargo.toml | 2 +- crates/test-util/Cargo.toml | 7 +++++-- crates/test-util/src/matchers.rs | 10 +++++----- crates/types/Cargo.toml | 6 +++--- crates/types/build.rs | 4 ++-- crates/types/src/lib.rs | 3 +++ crates/worker/Cargo.toml | 2 +- .../state_machine/command_interpreter/tests.rs | 2 +- tools/mock-service-endpoint/Cargo.toml | 2 +- tools/mock-service-endpoint/src/main.rs | 2 +- tools/restatectl/Cargo.toml | 2 +- tools/restatectl/src/commands/dump/cluster_state.rs | 2 +- 36 files changed, 70 insertions(+), 53 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7baf30b41..0449e6988 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,10 +121,10 @@ opentelemetry_sdk = { version = "0.22.1" } parking_lot = { version = "0.12" } paste = "1.0" pin-project = "1.0" -prost = "0.12.1" -prost-build = "0.12.1" +prost-0-12 = { package = "prost", version = "0.12.1" } +prost-build-0-12 = { package = "prost-build", version = "0.12.1" } prost-dto = { version = "0.0.2" } -prost-types = "0.12.1" +prost-types-0-12 = { package = "prost-types", version = "0.12.1" } rand = "0.8.5" rayon = { version = "1.10" } regress = { version = "0.10" } diff --git a/crates/admin/Cargo.toml b/crates/admin/Cargo.toml index 6da4259fc..64d592087 100644 --- a/crates/admin/Cargo.toml +++ b/crates/admin/Cargo.toml @@ -40,9 +40,9 @@ http = { workspace = true } http-body = { workspace = true } http-body-util = { workspace = true } okapi-operation = { version = "0.3.0-rc2", features = ["axum-integration"] } -prost = { workspace = true } +prost-0-12 = { workspace = true } prost-dto = { workspace = true } -prost-types = { workspace = true } +prost-types-0-12 = { workspace = true } restate-serde-util = { workspace = true, features = ["schema"] } schemars = { workspace = true } serde = { workspace = true } diff --git a/crates/admin/src/lib.rs b/crates/admin/src/lib.rs index 54c18b27f..d9ed7fc44 100644 --- a/crates/admin/src/lib.rs +++ b/crates/admin/src/lib.rs @@ -8,6 +8,8 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate prost_0_12 as prost; +extern crate prost_types_0_12 as prost_types; extern crate tonic_0_10 as tonic; pub mod cluster_controller; mod error; diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 4a8b77d0d..fa669e7f8 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -34,8 +34,8 @@ hyper = { workspace = true } metrics = { workspace = true } once_cell = { workspace = true } pin-project = { workspace = true } -prost = { workspace = true } -prost-types = { workspace = true } +prost-0-12 = { workspace = true } +prost-types-0-12 = { workspace = true } rand = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 8f8970770..b054de2d7 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -8,6 +8,8 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate prost_0_12 as prost; +extern crate prost_types_0_12 as prost_types; extern crate tonic_0_10 as tonic; mod metadata; diff --git a/crates/invoker-impl/Cargo.toml b/crates/invoker-impl/Cargo.toml index 35e8ab2e9..37fa5fe46 100644 --- a/crates/invoker-impl/Cargo.toml +++ b/crates/invoker-impl/Cargo.toml @@ -56,7 +56,7 @@ restate-test-util = { workspace = true } restate-types = { workspace = true } googletest = { workspace = true } -prost = { workspace = true } +prost-0-12 = { workspace = true } tempfile = { workspace = true } test-log = { workspace = true } tokio-util = { workspace = true } diff --git a/crates/metadata-store/Cargo.toml b/crates/metadata-store/Cargo.toml index ee827f968..c91d11b52 100644 --- a/crates/metadata-store/Cargo.toml +++ b/crates/metadata-store/Cargo.toml @@ -24,8 +24,8 @@ bytestring = { workspace = true } derive_builder = { workspace = true } futures = { workspace = true } humantime = { workspace = true } -prost = { workspace = true } -prost-types = { workspace = true } +prost-0-12 = { workspace = true } +prost-types-0-12 = { workspace = true } rocksdb = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } diff --git a/crates/metadata-store/src/lib.rs b/crates/metadata-store/src/lib.rs index 583e0832e..65bc2feaf 100644 --- a/crates/metadata-store/src/lib.rs +++ b/crates/metadata-store/src/lib.rs @@ -8,6 +8,8 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate prost_0_12 as prost; +extern crate prost_types_0_12 as prost_types; extern crate tonic_0_10 as tonic; mod grpc_svc; diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index cb9738f51..a4de37ec1 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -51,7 +51,7 @@ metrics-exporter-prometheus = { workspace = true } metrics-tracing-context = { version = "0.16.0" } metrics-util = { version = "0.17.0" } once_cell = { workspace = true } -prost-types = { workspace = true } +prost-types-0-12 = { workspace = true } rocksdb = { workspace = true } schemars = { workspace = true, optional = true } semver = { version = "1.0", features = ["serde"] } diff --git a/crates/partition-store/Cargo.toml b/crates/partition-store/Cargo.toml index e4a946fc0..4729db8f8 100644 --- a/crates/partition-store/Cargo.toml +++ b/crates/partition-store/Cargo.toml @@ -29,7 +29,7 @@ futures = { workspace = true } futures-util = { workspace = true } once_cell = { workspace = true } paste = { workspace = true } -prost = { workspace = true } +prost-0-12 = { workspace = true } rocksdb = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } diff --git a/crates/partition-store/src/keys.rs b/crates/partition-store/src/keys.rs index d7712346f..90da48217 100644 --- a/crates/partition-store/src/keys.rs +++ b/crates/partition-store/src/keys.rs @@ -11,7 +11,7 @@ use anyhow::anyhow; use bytes::{Buf, BufMut, Bytes, BytesMut}; use bytestring::ByteString; -use prost::encoding::encoded_len_varint; +use prost_0_12::encoding::encoded_len_varint; use std::mem; use strum_macros::EnumIter; @@ -576,13 +576,13 @@ impl KeyCodec for TimerKeyKind { #[inline] fn write_delimited(source: impl AsRef<[u8]>, target: &mut B) { let source = source.as_ref(); - prost::encoding::encode_varint(source.len() as u64, target); + prost_0_12::encoding::encode_varint(source.len() as u64, target); target.put(source); } #[inline] fn read_delimited(source: &mut B) -> crate::Result { - let len = prost::encoding::decode_varint(source) + let len = prost_0_12::encoding::decode_varint(source) .map_err(|error| StorageError::Generic(error.into()))?; // note: this is a zero-copy when the source is bytes::Bytes. Ok(source.copy_to_bytes(len as usize)) diff --git a/crates/serde-util/Cargo.toml b/crates/serde-util/Cargo.toml index 289e4e865..819d12ee7 100644 --- a/crates/serde-util/Cargo.toml +++ b/crates/serde-util/Cargo.toml @@ -10,7 +10,7 @@ publish = false [features] default = [] schema = ["dep:schemars"] -proto = ["dep:prost", "dep:bytes"] +proto = ["dep:prost-0-12", "dep:bytes"] [dependencies] bytes = { workspace = true, optional = true } @@ -19,7 +19,7 @@ http = { workspace = true } http-serde = { workspace = true } humantime = { workspace = true } iso8601 = "0.6.1" -prost = { workspace = true, optional = true } +prost-0-12 = { workspace = true, optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true } serde_with = { workspace = true } diff --git a/crates/serde-util/src/proto.rs b/crates/serde-util/src/proto.rs index 7c867bffc..58f81cd5e 100644 --- a/crates/serde-util/src/proto.rs +++ b/crates/serde-util/src/proto.rs @@ -19,7 +19,7 @@ pub struct ProtobufEncoded; impl SerializeAs for ProtobufEncoded where - T: prost::Message, + T: prost_0_12::Message, { fn serialize_as(source: &T, serializer: S) -> Result where @@ -31,7 +31,7 @@ where impl<'de, T> DeserializeAs<'de, T> for ProtobufEncoded where - T: prost::Message + Default, + T: prost_0_12::Message + Default, { fn deserialize_as(deserializer: D) -> Result where diff --git a/crates/service-protocol/Cargo.toml b/crates/service-protocol/Cargo.toml index e98f6b053..9a9bc44af 100644 --- a/crates/service-protocol/Cargo.toml +++ b/crates/service-protocol/Cargo.toml @@ -31,7 +31,7 @@ http-body-util = { workspace = true, optional = true } itertools = { workspace = true } once_cell = { workspace = true } paste = { workspace = true, optional = true } -prost = { workspace = true } +prost-0-12 = { workspace = true } regress = { workspace = true, optional = true } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } diff --git a/crates/service-protocol/src/codec.rs b/crates/service-protocol/src/codec.rs index 1bcdc32ea..78c1825f6 100644 --- a/crates/service-protocol/src/codec.rs +++ b/crates/service-protocol/src/codec.rs @@ -9,7 +9,7 @@ // by the Apache License, Version 2.0. use bytes::{Buf, BufMut, Bytes, BytesMut}; -use prost::Message; +use prost_0_12::Message; use restate_types::invocation::Header; use restate_types::journal::enriched::{EnrichedEntryHeader, EnrichedRawEntry}; use restate_types::journal::raw::*; @@ -35,7 +35,7 @@ macro_rules! match_decode { }; } -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, PartialEq, ::prost_0_12::Message)] struct NamedEntryTemplate { // By spec the field `name` is always tag 12 #[prost(string, optional, tag = "12")] diff --git a/crates/service-protocol/src/lib.rs b/crates/service-protocol/src/lib.rs index 63b8f7d9c..9df414302 100644 --- a/crates/service-protocol/src/lib.rs +++ b/crates/service-protocol/src/lib.rs @@ -10,6 +10,8 @@ //! This crate contains the code-generated structs of [service-protocol](https://github.com/restatedev/service-protocol) and the codec to use them. +extern crate prost_0_12 as prost; + pub const RESTATE_SERVICE_PROTOCOL_VERSION: u16 = 2; #[cfg(feature = "codec")] diff --git a/crates/service-protocol/src/message/encoding.rs b/crates/service-protocol/src/message/encoding.rs index 53f48cc90..68b1df436 100644 --- a/crates/service-protocol/src/message/encoding.rs +++ b/crates/service-protocol/src/message/encoding.rs @@ -24,7 +24,7 @@ use tracing::warn; #[code(restate_errors::RT0012)] pub enum EncodingError { #[error("cannot decode message type {0:?}. This looks like a bug of the SDK. Reason: {1:?}")] - DecodeMessage(MessageType, #[source] prost::DecodeError), + DecodeMessage(MessageType, #[source] prost_0_12::DecodeError), #[error(transparent)] UnknownMessageType(#[from] UnknownMessageType), #[error("hit message size limit: {0} >= {1}")] @@ -66,7 +66,7 @@ impl Encoder { &self, mut buf: impl BufMut, msg: ProtocolMessage, - ) -> Result<(), prost::EncodeError> { + ) -> Result<(), prost_0_12::EncodeError> { let header = generate_header(&msg); buf.put_u64(header.into()); @@ -101,7 +101,7 @@ fn generate_header(msg: &ProtocolMessage) -> MessageHeader { } } -fn encode_msg(msg: &ProtocolMessage, buf: &mut impl BufMut) -> Result<(), prost::EncodeError> { +fn encode_msg(msg: &ProtocolMessage, buf: &mut impl BufMut) -> Result<(), prost_0_12::EncodeError> { match msg { ProtocolMessage::Start(m) => m.encode(buf), ProtocolMessage::Completion(m) => m.encode(buf), @@ -239,7 +239,7 @@ impl DecoderState { fn decode_protocol_message( header: &MessageHeader, mut buf: impl Buf, -) -> Result { +) -> Result { Ok(match header.message_type() { MessageType::Start => ProtocolMessage::Start(service_protocol::StartMessage::decode(buf)?), MessageType::Completion => { diff --git a/crates/service-protocol/src/message/mod.rs b/crates/service-protocol/src/message/mod.rs index 9c6aa76a4..990e9bf56 100644 --- a/crates/service-protocol/src/message/mod.rs +++ b/crates/service-protocol/src/message/mod.rs @@ -12,7 +12,7 @@ //! including encoding and decoding of headers and message payloads. use bytes::Bytes; -use prost::Message; +use prost_0_12::Message; use restate_types::journal::raw::PlainRawEntry; use restate_types::journal::CompletionResult; use restate_types::journal::{Completion, EntryIndex}; diff --git a/crates/storage-api/Cargo.toml b/crates/storage-api/Cargo.toml index 20ac83b78..7b17f7803 100644 --- a/crates/storage-api/Cargo.toml +++ b/crates/storage-api/Cargo.toml @@ -20,12 +20,12 @@ bytestring = { workspace = true } derive_more = { workspace = true } futures-util = { workspace = true } opentelemetry = { workspace = true } -prost = { workspace = true } -prost-types = { workspace = true } +prost-0-12 = { workspace = true } +prost-types-0-12 = { workspace = true } serde = { workspace = true, optional = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } [build-dependencies] -prost-build = { workspace = true } \ No newline at end of file +prost-build-0-12 = { workspace = true } \ No newline at end of file diff --git a/crates/storage-api/build.rs b/crates/storage-api/build.rs index 2defa008a..fa4d901bb 100644 --- a/crates/storage-api/build.rs +++ b/crates/storage-api/build.rs @@ -9,7 +9,7 @@ // by the Apache License, Version 2.0. fn main() -> std::io::Result<()> { - prost_build::Config::new() + prost_build_0_12::Config::new() .bytes(["."]) // allow older protobuf compiler to be used .protoc_arg("--experimental_allow_proto3_optional") diff --git a/crates/storage-api/src/lib.rs b/crates/storage-api/src/lib.rs index daf109fd5..c2b762eb7 100644 --- a/crates/storage-api/src/lib.rs +++ b/crates/storage-api/src/lib.rs @@ -8,6 +8,9 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +extern crate prost_0_12 as prost; +extern crate prost_types_0_12 as prost_types; + use std::future::Future; /// Storage error diff --git a/crates/storage-api/src/storage.rs b/crates/storage-api/src/storage.rs index 259b56eb7..5561f4071 100644 --- a/crates/storage-api/src/storage.rs +++ b/crates/storage-api/src/storage.rs @@ -77,7 +77,7 @@ pub mod v1 { use bytes::{Buf, BufMut, Bytes}; use bytestring::ByteString; use opentelemetry::trace::TraceState; - use prost::Message; + use prost_0_12::Message; use restate_types::deployment::PinnedDeployment; use restate_types::errors::{IdDecodeError, InvocationError}; diff --git a/crates/storage-query-datafusion/Cargo.toml b/crates/storage-query-datafusion/Cargo.toml index bc904ce48..16738ac92 100644 --- a/crates/storage-query-datafusion/Cargo.toml +++ b/crates/storage-query-datafusion/Cargo.toml @@ -30,7 +30,7 @@ datafusion = { workspace = true } derive_builder = { workspace = true } futures = { workspace = true } paste = { workspace = true } -prost = { workspace = true } +prost-0-12 = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/storage-query-datafusion/src/journal/tests.rs b/crates/storage-query-datafusion/src/journal/tests.rs index fe8735899..77b63c89e 100644 --- a/crates/storage-query-datafusion/src/journal/tests.rs +++ b/crates/storage-query-datafusion/src/journal/tests.rs @@ -16,7 +16,7 @@ use datafusion::arrow::record_batch::RecordBatch; use futures::StreamExt; use googletest::all; use googletest::prelude::{assert_that, eq}; -use prost::Message; +use prost_0_12::Message; use restate_core::TaskCenterBuilder; use restate_service_protocol::codec::ProtobufRawEntryCodec; use restate_storage_api::journal_table::{JournalEntry, JournalTable}; diff --git a/crates/storage-query-postgres/Cargo.toml b/crates/storage-query-postgres/Cargo.toml index c97b6b88e..ed5f62e14 100644 --- a/crates/storage-query-postgres/Cargo.toml +++ b/crates/storage-query-postgres/Cargo.toml @@ -31,7 +31,7 @@ derive_builder = { workspace = true } futures = { workspace = true } paste = { workspace = true} pgwire = {version = "0.23", default-features = false, features = ["server-api-ring"]} -prost = {workspace = true} +prost-0-12 = {workspace = true} schemars = { workspace = true, optional = true } serde = { workspace = true } thiserror = { workspace = true } diff --git a/crates/test-util/Cargo.toml b/crates/test-util/Cargo.toml index d92c2c691..1925b7a19 100644 --- a/crates/test-util/Cargo.toml +++ b/crates/test-util/Cargo.toml @@ -7,11 +7,14 @@ rust-version.workspace = true license.workspace = true publish = false +[features] +prost = ["dep:prost-0-12"] + [dependencies] assert2 = { workspace = true } googletest = { workspace = true } pretty_assertions = "1.3" -prost = { workspace = true, optional = true } +prost-0-12 = { workspace = true, optional = true } [dev-dependencies] -prost-types = { workspace = true } +prost-types-0-12 = { workspace = true } diff --git a/crates/test-util/src/matchers.rs b/crates/test-util/src/matchers.rs index 82299bbcb..314c4f985 100644 --- a/crates/test-util/src/matchers.rs +++ b/crates/test-util/src/matchers.rs @@ -17,14 +17,14 @@ pub use prost::protobuf_decoded; #[cfg(feature = "prost")] mod prost { use googletest::matcher::{Matcher, MatcherResult}; - use prost::bytes; + use prost_0_12::bytes; use std::fmt::Debug; use std::marker::PhantomData; struct ProtobufDecodeMatcher(InnerMatcher, PhantomData); impl< - T: prost::Message + Default, + T: prost_0_12::Message + Default, B: bytes::Buf + Clone + Debug, InnerMatcher: Matcher, > Matcher for ProtobufDecodeMatcher @@ -54,7 +54,7 @@ mod prost { } // Decode Bytes as protobuf - pub fn protobuf_decoded( + pub fn protobuf_decoded( inner: impl Matcher, ) -> impl Matcher { ProtobufDecodeMatcher(inner, Default::default()) @@ -65,8 +65,8 @@ mod prost { use super::*; use googletest::{assert_that, matchers::eq}; - use prost::Message; - use prost_types::Timestamp; + use prost_0_12::Message; + use prost_types_0_12::Timestamp; #[test] fn timestamp() { diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 5ab5bea18..ade948101 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -39,9 +39,9 @@ itertools = { workspace = true } num-traits = { version = "0.2.17" } once_cell = { workspace = true } opentelemetry = { workspace = true } -prost = { workspace = true } +prost-0-12 = { workspace = true } prost-dto = { workspace = true } -prost-types = { workspace = true } +prost-types-0-12 = { workspace = true } rand = { workspace = true } regress = { workspace = true } schemars = { workspace = true, optional = true } @@ -72,7 +72,7 @@ test-log = { workspace = true } tokio = { workspace = true, features = ["test-util"] } [build-dependencies] -prost-build = { workspace = true } +prost-build-0-12 = { workspace = true } prettyplease = "0.2" schemars = { workspace = true } serde_json = { workspace = true } diff --git a/crates/types/build.rs b/crates/types/build.rs index 3a282c9d4..09b5c998b 100644 --- a/crates/types/build.rs +++ b/crates/types/build.rs @@ -17,7 +17,7 @@ use typify::{TypeSpace, TypeSpaceSettings}; fn main() -> std::io::Result<()> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - prost_build::Config::new() + prost_build_0_12::Config::new() .bytes(["."]) .protoc_arg("--experimental_allow_proto3_optional") .enum_attribute( @@ -84,7 +84,7 @@ fn main() -> std::io::Result<()> { } fn build_restate_proto(out_dir: &Path) -> std::io::Result<()> { - prost_build::Config::new() + prost_build_0_12::Config::new() .bytes(["."]) .enum_attribute( "TargetName", diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 36fd28d6c..a2cacad89 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -10,6 +10,9 @@ //! This crate contains the core types used by various Restate components. +extern crate prost_0_12 as prost; +extern crate prost_types_0_12 as prost_types; + mod base62_util; mod id_util; mod macros; diff --git a/crates/worker/Cargo.toml b/crates/worker/Cargo.toml index 92cbe4862..0b2a10d16 100644 --- a/crates/worker/Cargo.toml +++ b/crates/worker/Cargo.toml @@ -78,7 +78,7 @@ restate-service-protocol = { workspace = true, features = ["test-util"] } restate-storage-api = { workspace = true, features = ["test-util"] } restate-test-util = { workspace = true, features = ["prost"] } restate-types = { workspace = true, features = ["test-util"] } -prost = { workspace = true } +prost-0-12 = { workspace = true } googletest = { workspace = true } tempfile = { workspace = true } diff --git a/crates/worker/src/partition/state_machine/command_interpreter/tests.rs b/crates/worker/src/partition/state_machine/command_interpreter/tests.rs index e7c3755fb..d34c66137 100644 --- a/crates/worker/src/partition/state_machine/command_interpreter/tests.rs +++ b/crates/worker/src/partition/state_machine/command_interpreter/tests.rs @@ -14,7 +14,7 @@ use bytestring::ByteString; use futures::stream; use googletest::matcher::Matcher; use googletest::{all, any, assert_that, pat, unordered_elements_are}; -use prost::Message; +use prost_0_12::Message; use restate_invoker_api::EffectKind; use restate_service_protocol::awakeable_id::AwakeableIdentifier; use restate_service_protocol::codec::ProtobufRawEntryCodec; diff --git a/tools/mock-service-endpoint/Cargo.toml b/tools/mock-service-endpoint/Cargo.toml index b4bfd1cda..8dd55ccca 100644 --- a/tools/mock-service-endpoint/Cargo.toml +++ b/tools/mock-service-endpoint/Cargo.toml @@ -18,7 +18,7 @@ hyper = { workspace = true, features = ["server"] } hyper-util = { workspace = true, features = ["full"] } restate-service-protocol = { workspace = true, features = ["message", "codec"] } restate-types = { workspace = true } -prost = { workspace = true } +prost-0-12 = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } diff --git a/tools/mock-service-endpoint/src/main.rs b/tools/mock-service-endpoint/src/main.rs index eacf74257..942667d16 100644 --- a/tools/mock-service-endpoint/src/main.rs +++ b/tools/mock-service-endpoint/src/main.rs @@ -13,7 +13,7 @@ use hyper::server::conn::http2; use hyper::service::service_fn; use hyper::{Request, Response}; use hyper_util::rt::{TokioExecutor, TokioIo, TokioTimer}; -use prost::Message; +use prost_0_12::Message; use tokio::net::TcpListener; use tracing::{debug, error, info}; use tracing_subscriber::filter::LevelFilter; diff --git a/tools/restatectl/Cargo.toml b/tools/restatectl/Cargo.toml index 46d9b76f3..c81279a06 100644 --- a/tools/restatectl/Cargo.toml +++ b/tools/restatectl/Cargo.toml @@ -19,7 +19,7 @@ clap-verbosity-flag = { version = "2.0.1" } cling = { version = "0.1.0", default-features = false, features = ["derive"] } crossterm = { version = "0.27.0" } ctrlc = { version = "3.4" } -prost-types = { workspace = true } +prost-types-0-12 = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } tokio-stream = { workspace = true } diff --git a/tools/restatectl/src/commands/dump/cluster_state.rs b/tools/restatectl/src/commands/dump/cluster_state.rs index 642aadebb..04c6ab565 100644 --- a/tools/restatectl/src/commands/dump/cluster_state.rs +++ b/tools/restatectl/src/commands/dump/cluster_state.rs @@ -185,7 +185,7 @@ fn render_replay_status(status: ReplayStatus, target_lsn: Option) -> Cell { } } -fn render_as_duration(ts: Option, tense: Tense) -> Cell { +fn render_as_duration(ts: Option, tense: Tense) -> Cell { let ts: Option = ts .map(TryInto::try_into) .transpose() From c211b2afc77ca2e944e4578cd6ec1f4c5fa8766e Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Wed, 24 Jul 2024 12:46:42 +0200 Subject: [PATCH 3/5] Update metadata-store crate to use prost 0.13, tonic 0.12 and hyper 1.4 This fixes #1732. --- Cargo.lock | 234 +++++++++++++---- Cargo.toml | 7 + crates/core/src/task_center_types.rs | 2 + crates/metadata-store/Cargo.toml | 19 +- crates/metadata-store/build.rs | 2 +- crates/metadata-store/src/grpc_svc.rs | 5 +- crates/metadata-store/src/lib.rs | 4 - .../metadata-store/src/local/grpc/client.rs | 8 +- .../metadata-store/src/local/grpc/handler.rs | 2 +- crates/metadata-store/src/local/grpc/mod.rs | 1 + .../metadata-store/src/local/grpc/net_util.rs | 238 ++++++++++++++++++ crates/metadata-store/src/local/service.rs | 38 +-- crates/metadata-store/src/local/tests.rs | 8 +- 13 files changed, 473 insertions(+), 95 deletions(-) create mode 100644 crates/metadata-store/src/local/grpc/net_util.rs diff --git a/Cargo.lock b/Cargo.lock index 438fe8029..37bdf1cb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,7 +400,7 @@ dependencies = [ "bytes", "futures", "paste", - "prost", + "prost 0.12.3", "tokio", "tonic 0.10.2", ] @@ -1749,8 +1749,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" dependencies = [ "futures-core", - "prost", - "prost-types", + "prost 0.12.3", + "prost-types 0.12.3", "tonic 0.10.2", "tracing-core", ] @@ -1767,7 +1767,7 @@ dependencies = [ "futures-task", "hdrhistogram", "humantime", - "prost-types", + "prost-types 0.12.3", "serde", "serde_json", "thread_local", @@ -3194,6 +3194,19 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.6" @@ -3960,7 +3973,7 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-util", - "prost", + "prost 0.12.3", "restate-service-protocol", "restate-types", "serde", @@ -4248,7 +4261,7 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.30", "hyper-rustls 0.24.1", - "hyper-timeout", + "hyper-timeout 0.4.1", "jsonwebtoken", "once_cell", "percent-encoding", @@ -4397,7 +4410,7 @@ dependencies = [ "opentelemetry-proto", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "prost", + "prost 0.12.3", "thiserror", "tokio", "tonic 0.11.0", @@ -4411,7 +4424,7 @@ checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4" dependencies = [ "opentelemetry", "opentelemetry_sdk", - "prost", + "prost 0.12.3", "tonic 0.11.0", ] @@ -4883,7 +4896,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.3", +] + +[[package]] +name = "prost" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +dependencies = [ + "bytes", + "prost-derive 0.13.1", ] [[package]] @@ -4900,14 +4923,35 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.12.3", + "prost-types 0.12.3", "regex", "syn 2.0.65", "tempfile", "which", ] +[[package]] +name = "prost-build" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1" +dependencies = [ + "bytes", + "heck 0.5.0", + "itertools 0.13.0", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost 0.13.1", + "prost-types 0.13.1", + "regex", + "syn 2.0.65", + "tempfile", +] + [[package]] name = "prost-derive" version = "0.12.3" @@ -4921,6 +4965,19 @@ dependencies = [ "syn 2.0.65", ] +[[package]] +name = "prost-derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +dependencies = [ + "anyhow", + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.65", +] + [[package]] name = "prost-dto" version = "0.0.2" @@ -4961,7 +5018,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" dependencies = [ - "prost", + "prost 0.12.3", +] + +[[package]] +name = "prost-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +dependencies = [ + "prost 0.13.1", ] [[package]] @@ -5341,9 +5407,9 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "okapi-operation", - "prost", + "prost 0.12.3", "prost-dto", - "prost-types", + "prost-types 0.12.3", "restate-admin-rest-model", "restate-bifrost", "restate-core", @@ -5365,7 +5431,7 @@ dependencies = [ "thiserror", "tokio", "tonic 0.10.2", - "tonic-build", + "tonic-build 0.11.0", "tower", "tracing", "tracing-subscriber", @@ -5573,8 +5639,8 @@ dependencies = [ "metrics 0.23.0", "once_cell", "pin-project", - "prost", - "prost-types", + "prost 0.12.3", + "prost-types 0.12.3", "rand", "restate-test-util", "restate-types", @@ -5589,7 +5655,7 @@ dependencies = [ "tokio-stream", "tokio-util", "tonic 0.10.2", - "tonic-build", + "tonic-build 0.11.0", "tower", "tracing", "tracing-subscriber", @@ -5761,7 +5827,7 @@ dependencies = [ "opentelemetry", "opentelemetry-http", "opentelemetry_sdk", - "prost", + "prost 0.12.3", "restate-core", "restate-errors", "restate-fs-util", @@ -5844,9 +5910,12 @@ dependencies = [ "flexbuffers", "futures", "googletest", + "http 1.1.0", "humantime", - "prost", - "prost-types", + "hyper 1.4.1", + "hyper-util", + "prost 0.13.1", + "prost-types 0.13.1", "restate-core", "restate-rocksdb", "restate-types", @@ -5858,12 +5927,14 @@ dependencies = [ "test-log", "thiserror", "tokio", - "tonic 0.10.2", - "tonic-build", + "tokio-stream", + "tokio-util", + "tonic 0.12.1", + "tonic-build 0.12.1", "tonic-health", - "tonic-reflection", + "tonic-reflection 0.12.1", "tower", - "tower-http 0.4.4", + "tower-http 0.5.2", "tracing", "tracing-subscriber", ] @@ -5894,7 +5965,7 @@ dependencies = [ "metrics-tracing-context 0.16.0", "metrics-util 0.17.0", "once_cell", - "prost-types", + "prost-types 0.12.3", "restate-admin", "restate-bifrost", "restate-core", @@ -5922,7 +5993,7 @@ dependencies = [ "tokio-stream", "tokio-util", "tonic 0.10.2", - "tonic-reflection", + "tonic-reflection 0.10.2", "tower", "tower-http 0.4.4", "tracing", @@ -5947,7 +6018,7 @@ dependencies = [ "num-bigint", "once_cell", "paste", - "prost", + "prost 0.12.3", "rand", "restate-core", "restate-errors", @@ -6024,7 +6095,7 @@ dependencies = [ "http-serde", "humantime", "iso8601", - "prost", + "prost 0.12.3", "schemars", "serde", "serde_json", @@ -6129,7 +6200,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "paste", - "prost", + "prost 0.12.3", "regress 0.10.0", "restate-base64-util", "restate-errors", @@ -6158,9 +6229,9 @@ dependencies = [ "derive_more", "futures-util", "opentelemetry", - "prost", - "prost-build", - "prost-types", + "prost 0.12.3", + "prost-build 0.12.3", + "prost-types 0.12.3", "restate-types", "serde", "strum 0.26.2", @@ -6183,7 +6254,7 @@ dependencies = [ "futures", "googletest", "paste", - "prost", + "prost 0.12.3", "restate-core", "restate-invoker-api", "restate-partition-store", @@ -6214,7 +6285,7 @@ dependencies = [ "futures", "paste", "pgwire", - "prost", + "prost 0.12.3", "restate-core", "restate-errors", "restate-partition-store", @@ -6236,8 +6307,8 @@ dependencies = [ "assert2", "googletest", "pretty_assertions", - "prost", - "prost-types", + "prost 0.12.3", + "prost-types 0.12.3", ] [[package]] @@ -6321,10 +6392,10 @@ dependencies = [ "once_cell", "opentelemetry", "prettyplease", - "prost", - "prost-build", + "prost 0.12.3", + "prost-build 0.12.3", "prost-dto", - "prost-types", + "prost-types 0.12.3", "rand", "regress 0.10.0", "restate-base64-util", @@ -6403,7 +6474,7 @@ dependencies = [ "metrics 0.23.0", "opentelemetry", "pin-project", - "prost", + "prost 0.12.3", "rand", "restate-bifrost", "restate-core", @@ -6455,7 +6526,7 @@ dependencies = [ "cling", "crossterm 0.27.0", "ctrlc", - "prost-types", + "prost-types 0.12.3", "restate-admin", "restate-cli-util", "restate-types", @@ -7605,10 +7676,10 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-timeout", + "hyper-timeout 0.4.1", "percent-encoding", "pin-project", - "prost", + "prost 0.12.3", "tokio", "tokio-stream", "tower", @@ -7632,10 +7703,40 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-timeout", + "hyper-timeout 0.4.1", + "percent-encoding", + "pin-project", + "prost 0.12.3", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.7.5", + "base64 0.22.0", + "bytes", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-timeout 0.5.1", + "hyper-util", "percent-encoding", "pin-project", - "prost", + "prost 0.13.1", + "socket2", "tokio", "tokio-stream", "tower", @@ -7652,22 +7753,35 @@ checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" dependencies = [ "prettyplease", "proc-macro2", - "prost-build", + "prost-build 0.12.3", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "tonic-build" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "568392c5a2bd0020723e3f387891176aabafe36fd9fcd074ad309dfa0c8eb964" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build 0.13.1", "quote", "syn 2.0.65", ] [[package]] name = "tonic-health" -version = "0.10.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f80db390246dfb46553481f6024f0082ba00178ea495dbb99e70ba9a4fafb5e1" +checksum = "e1e10e6a96ee08b6ce443487d4368442d328d0e746f3681f81127f7dc41b4955" dependencies = [ "async-stream", - "prost", + "prost 0.13.1", "tokio", "tokio-stream", - "tonic 0.10.2", + "tonic 0.12.1", ] [[package]] @@ -7676,13 +7790,26 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fa37c513df1339d197f4ba21d28c918b9ef1ac1768265f11ecb6b7f1cba1b76" dependencies = [ - "prost", - "prost-types", + "prost 0.12.3", + "prost-types 0.12.3", "tokio", "tokio-stream", "tonic 0.10.2", ] +[[package]] +name = "tonic-reflection" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b742c83ad673e9ab5b4ce0981f7b9e8932be9d60e8682cbf9120494764dbc173" +dependencies = [ + "prost 0.13.1", + "prost-types 0.13.1", + "tokio", + "tokio-stream", + "tonic 0.12.1", +] + [[package]] name = "tower" version = "0.4.13" @@ -7738,6 +7865,7 @@ dependencies = [ "pin-project-lite", "tower-layer", "tower-service", + "tracing", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0449e6988..44460de89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,9 +121,12 @@ opentelemetry_sdk = { version = "0.22.1" } parking_lot = { version = "0.12" } paste = "1.0" pin-project = "1.0" +prost = { version = "0.13.1" } prost-0-12 = { package = "prost", version = "0.12.1" } +prost-build = { version = "0.13.1" } prost-build-0-12 = { package = "prost-build", version = "0.12.1" } prost-dto = { version = "0.0.2" } +prost-types = { version = "0.13.1" } prost-types-0-12 = { package = "prost-types", version = "0.12.1" } rand = "0.8.5" rayon = { version = "1.10" } @@ -152,9 +155,13 @@ thiserror = "1.0" tokio = { version = "1.29", default-features = false, features = ["rt-multi-thread", "signal", "macros", ] } tokio-stream = "0.1.14" tokio-util = { version = "0.7.10" } +tonic = { version = "0.12.1", default-features = false } tonic-0-10 = { package = "tonic", version = "0.10.2", default-features = false } +tonic-reflection = { version = "0.12.1" } tonic-reflection-0-10 = { package = "tonic-reflection", version = "0.10.2" } +tonic-health = { version = "0.12.1" } tonic-health-0-10 = { package = "tonic-health", version = "0.10.2" } +tonic-build = { version = "0.12.1" } tonic-build-0-11 = { package = "tonic-build", version = "0.11.0" } tower = "0.4" tower-http = { version = "0.5.2", default-features = false } diff --git a/crates/core/src/task_center_types.rs b/crates/core/src/task_center_types.rs index 3db841199..af10d3ae0 100644 --- a/crates/core/src/task_center_types.rs +++ b/crates/core/src/task_center_types.rs @@ -62,6 +62,8 @@ pub enum TaskKind { #[strum(props(OnCancel = "abort"))] MetadataBackgroundSync, RpcServer, + #[strum(props(OnCancel = "abort", OnError = "log"))] + RpcConnection, /// A type for ingress until we start enforcing timeouts for inflight requests. This enables us /// to shutdown cleanly without waiting indefinitely. #[strum(props(OnCancel = "abort", runtime = "ingress"))] diff --git a/crates/metadata-store/Cargo.toml b/crates/metadata-store/Cargo.toml index c91d11b52..79478b04d 100644 --- a/crates/metadata-store/Cargo.toml +++ b/crates/metadata-store/Cargo.toml @@ -23,20 +23,25 @@ bytes = { workspace = true } bytestring = { workspace = true } derive_builder = { workspace = true } futures = { workspace = true } +http = { workspace = true } humantime = { workspace = true } -prost-0-12 = { workspace = true } -prost-types-0-12 = { workspace = true } +hyper = { workspace = true } +hyper-util = { workspace = true } +prost = { workspace = true } +prost-types = { workspace = true } rocksdb = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } static_assertions = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } -tonic-0-10 = { workspace = true, features = ["transport", "codegen", "prost"] } -tonic-reflection-0-10 = { workspace = true } -tonic-health-0-10 = { workspace = true } +tokio-stream = { workspace = true } +tokio-util = { workspace = true, features = ["net"] } +tonic = { workspace = true, features = ["transport", "codegen", "prost"] } +tonic-reflection = { workspace = true } +tonic-health = { workspace = true } tower = { workspace = true } -tower-http-0-4 = { package = "tower-http", version = "0.4", features = ["trace"] } +tower-http = { workspace = true, features = ["trace"] } tracing = { workspace = true } [dev-dependencies] @@ -51,4 +56,4 @@ test-log = { workspace = true } tracing-subscriber = { workspace = true } [build-dependencies] -tonic-build-0-11 = { workspace = true } +tonic-build = { workspace = true } diff --git a/crates/metadata-store/build.rs b/crates/metadata-store/build.rs index de0038e83..b2b100490 100644 --- a/crates/metadata-store/build.rs +++ b/crates/metadata-store/build.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - tonic_build_0_11::configure() + tonic_build::configure() .bytes(["."]) .file_descriptor_set_path(out_dir.join("metadata_store_svc.bin")) // allow older protobuf compiler to be used diff --git a/crates/metadata-store/src/grpc_svc.rs b/crates/metadata-store/src/grpc_svc.rs index 61c698800..0b4034460 100644 --- a/crates/metadata-store/src/grpc_svc.rs +++ b/crates/metadata-store/src/grpc_svc.rs @@ -8,7 +8,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -tonic_0_10::include_proto!("dev.restate.metadata_store_svc"); +tonic::include_proto!("dev.restate.metadata_store_svc"); -pub const FILE_DESCRIPTOR_SET: &[u8] = - tonic_0_10::include_file_descriptor_set!("metadata_store_svc"); +pub const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("metadata_store_svc"); diff --git a/crates/metadata-store/src/lib.rs b/crates/metadata-store/src/lib.rs index 65bc2feaf..198840cc9 100644 --- a/crates/metadata-store/src/lib.rs +++ b/crates/metadata-store/src/lib.rs @@ -8,10 +8,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -extern crate prost_0_12 as prost; -extern crate prost_types_0_12 as prost_types; -extern crate tonic_0_10 as tonic; - mod grpc_svc; pub mod local; diff --git a/crates/metadata-store/src/local/grpc/client.rs b/crates/metadata-store/src/local/grpc/client.rs index 2732fa7af..196a12de8 100644 --- a/crates/metadata-store/src/local/grpc/client.rs +++ b/crates/metadata-store/src/local/grpc/client.rs @@ -10,18 +10,18 @@ use async_trait::async_trait; use bytestring::ByteString; -use tonic_0_10::transport::Channel; -use tonic_0_10::{Code, Status}; +use tonic::transport::Channel; +use tonic::{Code, Status}; use restate_core::metadata_store::{ MetadataStore, Precondition, ReadError, VersionedValue, WriteError, }; -use restate_core::network::grpc_util::create_grpc_channel_from_advertised_address; use restate_types::net::AdvertisedAddress; use restate_types::Version; use crate::grpc_svc::metadata_store_svc_client::MetadataStoreSvcClient; use crate::grpc_svc::{DeleteRequest, GetRequest, PutRequest}; +use crate::local::grpc::net_util::create_tonic_channel_from_advertised_address; use crate::local::grpc::pb_conversions::ConversionError; /// Client end to interact with the [`LocalMetadataStore`]. @@ -31,7 +31,7 @@ pub struct LocalMetadataStoreClient { } impl LocalMetadataStoreClient { pub fn new(metadata_store_address: AdvertisedAddress) -> Self { - let channel = create_grpc_channel_from_advertised_address(metadata_store_address) + let channel = create_tonic_channel_from_advertised_address(metadata_store_address) .expect("should not fail"); Self { diff --git a/crates/metadata-store/src/local/grpc/handler.rs b/crates/metadata-store/src/local/grpc/handler.rs index e9faafd44..79d948ddd 100644 --- a/crates/metadata-store/src/local/grpc/handler.rs +++ b/crates/metadata-store/src/local/grpc/handler.rs @@ -14,7 +14,7 @@ use crate::local::grpc::pb_conversions::ConversionError; use crate::local::store::{Error, MetadataStoreRequest, RequestSender}; use async_trait::async_trait; use tokio::sync::oneshot; -use tonic_0_10::{Request, Response, Status}; +use tonic::{Request, Response, Status}; /// Grpc svc handler for the [`LocalMetadataStore`]. #[derive(Debug)] diff --git a/crates/metadata-store/src/local/grpc/mod.rs b/crates/metadata-store/src/local/grpc/mod.rs index 6d34ffad7..47e4ff962 100644 --- a/crates/metadata-store/src/local/grpc/mod.rs +++ b/crates/metadata-store/src/local/grpc/mod.rs @@ -10,6 +10,7 @@ pub mod client; pub mod handler; +pub mod net_util; pub mod pb_conversions { use crate::grpc_svc; diff --git a/crates/metadata-store/src/local/grpc/net_util.rs b/crates/metadata-store/src/local/grpc/net_util.rs new file mode 100644 index 000000000..fb7ced286 --- /dev/null +++ b/crates/metadata-store/src/local/grpc/net_util.rs @@ -0,0 +1,238 @@ +// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH. +// All rights reserved. +// +// Use of this software is governed by the Business Source License +// included in the LICENSE file. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0. + +use http::Uri; +use hyper::body::{Body, Incoming}; +use hyper::rt::{Read, Write}; +use hyper_util::rt::TokioIo; +use restate_core::{cancellation_watcher, task_center, ShutdownError, TaskCenter, TaskKind}; +use restate_types::errors::GenericError; +use restate_types::net::{AdvertisedAddress, BindAddress}; +use std::fmt::Debug; +use std::future::Future; +use std::net::SocketAddr; +use std::path::PathBuf; +use std::time::Duration; +use tokio::io; +use tokio::net::{TcpListener, UnixListener, UnixStream}; +use tokio_util::net::Listener; +use tonic::transport::{Channel, Endpoint}; +use tracing::{debug, info, instrument, Span}; + +pub fn create_tonic_channel_from_advertised_address( + address: AdvertisedAddress, +) -> Result { + let channel = match address { + AdvertisedAddress::Uds(uds_path) => { + // dummy endpoint required to specify an uds connector, it is not used anywhere + Endpoint::try_from("http://127.0.0.1") + .expect("/ should be a valid Uri") + .connect_with_connector_lazy(tower::service_fn(move |_: Uri| { + let uds_path = uds_path.clone(); + async move { + Ok::<_, io::Error>(TokioIo::new(UnixStream::connect(uds_path).await?)) + } + })) + } + AdvertisedAddress::Http(uri) => { + // todo: Make the channel settings configurable + Channel::builder(uri) + .connect_timeout(Duration::from_secs(5)) + // todo: configure the channel from configuration file + .http2_adaptive_window(true) + .connect_lazy() + } + }; + Ok(channel) +} + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("failed binding to address '{address}': {source}")] + TcpBinding { + address: SocketAddr, + #[source] + source: io::Error, + }, + #[error("failed opening uds '{uds_path}': {source}")] + UdsBinding { + uds_path: PathBuf, + #[source] + source: io::Error, + }, + #[error("failed handling hyper connection: {0}")] + HandlingConnection(#[from] GenericError), + #[error("failed listening on incoming connections: {0}")] + Listening(#[from] io::Error), + #[error(transparent)] + Shutdown(#[from] ShutdownError), +} + +#[instrument(level = "info", skip_all, fields(server_name = %server_name, uds.path = tracing::field::Empty, net.host.addr = tracing::field::Empty, net.host.port = tracing::field::Empty))] +pub async fn run_hyper_server( + bind_address: &BindAddress, + service: S, + server_name: &'static str, +) -> Result<(), Error> +where + S: hyper::service::Service, Response = hyper::Response> + + Send + + Clone + + 'static, + S::Error: Into>, + S::Future: Send, + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + match bind_address { + BindAddress::Uds(uds_path) => { + let unix_listener = UnixListener::bind(uds_path).map_err(|err| Error::UdsBinding { + uds_path: uds_path.clone(), + source: err, + })?; + + Span::current().record("uds.path", uds_path.display().to_string()); + info!("Server listening"); + + run_listener_loop(unix_listener, service, server_name).await?; + } + BindAddress::Socket(socket_addr) => { + let tcp_listener = + TcpListener::bind(socket_addr) + .await + .map_err(|err| Error::TcpBinding { + address: *socket_addr, + source: err, + })?; + + let local_addr = tcp_listener.local_addr().map_err(|err| Error::TcpBinding { + address: *socket_addr, + source: err, + })?; + + Span::current().record("net.host.addr", local_addr.ip().to_string()); + Span::current().record("net.host.port", local_addr.port()); + info!("Server listening"); + + run_listener_loop(tcp_listener, service, server_name).await?; + } + } + + debug!("Stopped server"); + + Ok(()) +} + +async fn run_listener_loop( + mut listener: L, + service: S, + server_name: &'static str, +) -> Result<(), Error> +where + L: Listener, + L::Io: Send + Unpin + 'static, + L::Addr: Debug, + S: hyper::service::Service, Response = hyper::Response> + + Send + + Clone + + 'static, + S::Error: Into>, + S::Future: Send, + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + let mut shutdown = std::pin::pin!(cancellation_watcher()); + let tc = task_center(); + let executor = TaskCenterExecutor::new(tc.clone(), server_name); + loop { + tokio::select! { + biased; + _ = &mut shutdown => { + break; + } + incoming_connection = listener.accept() => { + let (stream, remote_addr) = incoming_connection?; + let io = TokioIo::new(stream); + + debug!("Accepting incoming connection from '{remote_addr:?}'."); + + tc.spawn_child(TaskKind::RpcConnection, server_name, None, handle_connection( + io, + service.clone(), + executor.clone(), + ))?; + } + } + } + + Ok(()) +} + +async fn handle_connection( + io: I, + service: S, + executor: TaskCenterExecutor, +) -> anyhow::Result<()> +where + S: hyper::service::Service, Response = hyper::Response> + + Send + + Clone + + 'static, + S::Error: Into>, + S::Future: Send, + B: Body + Send + 'static, + B::Data: Send, + B::Error: Into>, + I: Read + Write + Unpin + 'static, +{ + let builder = hyper_util::server::conn::auto::Builder::new(executor); + let connection = builder.serve_connection(io, service); + + tokio::select! { + res = connection => { + // propagate errors + res.map_err(Error::HandlingConnection)?; + }, + _ = cancellation_watcher() => {} + } + + Ok(()) +} + +#[derive(Clone)] +struct TaskCenterExecutor { + task_center: TaskCenter, + name: &'static str, +} + +impl TaskCenterExecutor { + fn new(task_center: TaskCenter, name: &'static str) -> Self { + Self { task_center, name } + } +} + +impl hyper::rt::Executor for TaskCenterExecutor +where + F: Future + 'static + Send, + F::Output: Send + 'static, +{ + fn execute(&self, fut: F) { + // ignore shutdown error + let _ = + self.task_center + .spawn_child(TaskKind::RpcConnection, self.name, None, async move { + // ignore the future output + let _ = fut.await; + Ok(()) + }); + } +} diff --git a/crates/metadata-store/src/local/service.rs b/crates/metadata-store/src/local/service.rs index 935bc3e0f..07a2f8075 100644 --- a/crates/metadata-store/src/local/service.rs +++ b/crates/metadata-store/src/local/service.rs @@ -8,17 +8,21 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use tonic_0_10::server::NamedService; - -use restate_core::network::grpc_util; -use restate_core::{cancellation_watcher, task_center, ShutdownError, TaskKind}; +use http::Request; +use hyper::body::Incoming; +use hyper_util::service::TowerToHyperService; +use restate_core::{task_center, ShutdownError, TaskKind}; use restate_rocksdb::RocksError; use restate_types::config::{MetadataStoreOptions, RocksDbOptions}; use restate_types::live::BoxedLiveLoad; +use tonic::body::boxed; +use tonic::server::NamedService; +use tower::ServiceExt; use crate::grpc_svc; use crate::grpc_svc::metadata_store_svc_server::MetadataStoreSvcServer; use crate::local::grpc::handler::LocalMetadataStoreHandler; +use crate::local::grpc::net_util; use crate::local::store::LocalMetadataStore; pub struct LocalMetadataStoreService { @@ -29,9 +33,9 @@ pub struct LocalMetadataStoreService { #[derive(Debug, thiserror::Error)] pub enum Error { #[error("failed running grpc server: {0}")] - GrpcServer(#[from] grpc_util::Error), + GrpcServer(#[from] net_util::Error), #[error("error while running server server grpc reflection service: {0}")] - GrpcReflection(#[from] tonic_reflection_0_10::server::Error), + GrpcReflection(#[from] tonic_reflection::server::Error), #[error("system is shutting down")] Shutdown(#[from] ShutdownError), #[error("rocksdb error: {0}")] @@ -62,40 +66,38 @@ impl LocalMetadataStoreService { let bind_address = options.bind_address.clone(); let store = LocalMetadataStore::create(options, rocksdb_options).await?; // Trace layer - let span_factory = tower_http_0_4::trace::DefaultMakeSpan::new() + let span_factory = tower_http::trace::DefaultMakeSpan::new() .include_headers(true) .level(tracing::Level::ERROR); - let reflection_service_builder = tonic_reflection_0_10::server::Builder::configure() + let reflection_service_builder = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(grpc_svc::FILE_DESCRIPTOR_SET); - let (mut health_reporter, health_service) = tonic_health_0_10::server::health_reporter(); + let (mut health_reporter, health_service) = tonic_health::server::health_reporter(); health_reporter .set_serving::>() .await; let server_builder = tonic::transport::Server::builder() - .layer(tower_http_0_4::trace::TraceLayer::new_for_grpc().make_span_with(span_factory)) + .layer(tower_http::trace::TraceLayer::new_for_grpc().make_span_with(span_factory)) .add_service(health_service) .add_service(MetadataStoreSvcServer::new(LocalMetadataStoreHandler::new( store.request_sender(), ))) .add_service(reflection_service_builder.build()?); - let service = server_builder.into_service(); + let service = TowerToHyperService::new( + server_builder + .into_service() + .map_request(|req: Request| req.map(boxed)), + ); task_center().spawn_child( TaskKind::RpcServer, "metadata-store-grpc", None, async move { - grpc_util::run_hyper_server( - &bind_address, - service, - cancellation_watcher(), - "metadata-store-grpc", - ) - .await?; + net_util::run_hyper_server(&bind_address, service, "metadata-store-grpc").await?; Ok(()) }, )?; diff --git a/crates/metadata-store/src/local/tests.rs b/crates/metadata-store/src/local/tests.rs index 056c24a5a..8de795448 100644 --- a/crates/metadata-store/src/local/tests.rs +++ b/crates/metadata-store/src/local/tests.rs @@ -15,10 +15,9 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use serde::{Deserialize, Serialize}; use test_log::test; -use tonic_health_0_10::pb::health_client::HealthClient; -use tonic_health_0_10::pb::HealthCheckRequest; +use tonic_health::pb::health_client::HealthClient; +use tonic_health::pb::HealthCheckRequest; -use restate_core::network::grpc_util::create_grpc_channel_from_advertised_address; use restate_core::{MockNetworkSender, TaskCenter, TaskKind, TestCoreEnv, TestCoreEnvBuilder}; use restate_rocksdb::RocksDbManager; use restate_types::config::{ @@ -30,6 +29,7 @@ use restate_types::retries::RetryPolicy; use restate_types::{flexbuffers_storage_encode_decode, Version, Versioned}; use crate::local::grpc::client::LocalMetadataStoreClient; +use crate::local::grpc::net_util::create_tonic_channel_from_advertised_address; use crate::local::service::LocalMetadataStoreService; use crate::{MetadataStoreClient, Precondition, WriteError}; @@ -358,7 +358,7 @@ async fn start_metadata_store( )?; // await start-up of metadata store - let health_client = HealthClient::new(create_grpc_channel_from_advertised_address( + let health_client = HealthClient::new(create_tonic_channel_from_advertised_address( advertised_address.clone(), )?); let retry_policy = RetryPolicy::exponential(Duration::from_millis(10), 2.0, None, None); From 8ea75044bb4b4504b685c302b1336fbc0d6f8d72 Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Wed, 24 Jul 2024 15:38:00 +0200 Subject: [PATCH 4/5] Bump prost and tonic dependency to 0.13.1 and 0.12.1 respectively This commit bumps the prost dependency to version 0.13.1 and tonic to 0.12.1. We needed to keep a tonic 0.10 dependency in the restate-node and restate-admin crates because the arrow-flight dependency uses it and we need to convert from tonic_0_10::Status to tonic::Status. This fixes #1745. --- Cargo.lock | 129 ++++--------- Cargo.toml | 6 - crates/admin/Cargo.toml | 9 +- crates/admin/build.rs | 2 +- .../admin/src/cluster_controller/protobuf.rs | 4 +- crates/admin/src/lib.rs | 3 - crates/admin/src/service.rs | 2 +- crates/admin/src/state.rs | 2 +- crates/admin/src/storage_query/error.rs | 2 +- crates/admin/src/storage_query/query.rs | 45 ++++- crates/core/Cargo.toml | 12 +- crates/core/build.rs | 2 +- crates/core/src/lib.rs | 4 - crates/core/src/network/connection_manager.rs | 19 +- crates/core/src/network/error.rs | 30 +-- crates/core/src/network/grpc_util.rs | 179 ------------------ crates/core/src/network/mod.rs | 2 +- .../grpc => core/src/network}/net_util.rs | 2 +- crates/core/src/network/protobuf.rs | 4 +- crates/invoker-impl/Cargo.toml | 2 +- .../metadata-store/src/local/grpc/client.rs | 2 +- crates/metadata-store/src/local/grpc/mod.rs | 1 - crates/metadata-store/src/local/service.rs | 11 +- crates/metadata-store/src/local/tests.rs | 2 +- crates/node/Cargo.toml | 13 +- .../network_server/handler/cluster_ctrl.rs | 4 +- crates/node/src/network_server/handler/mod.rs | 2 +- .../node/src/network_server/handler/node.rs | 56 +++++- crates/node/src/network_server/multiplex.rs | 13 +- crates/node/src/network_server/service.rs | 40 ++-- crates/node/src/roles/admin.rs | 2 +- crates/node/src/roles/worker.rs | 2 +- crates/partition-store/Cargo.toml | 2 +- crates/partition-store/src/keys.rs | 6 +- crates/serde-util/Cargo.toml | 4 +- crates/serde-util/src/proto.rs | 4 +- crates/service-protocol/Cargo.toml | 2 +- crates/service-protocol/src/codec.rs | 4 +- crates/service-protocol/src/lib.rs | 2 - .../service-protocol/src/message/encoding.rs | 8 +- crates/service-protocol/src/message/mod.rs | 2 +- crates/storage-api/Cargo.toml | 6 +- crates/storage-api/build.rs | 2 +- crates/storage-api/src/lib.rs | 3 - crates/storage-api/src/storage.rs | 2 +- crates/storage-query-datafusion/Cargo.toml | 2 +- .../src/journal/tests.rs | 2 +- crates/storage-query-postgres/Cargo.toml | 2 +- crates/test-util/Cargo.toml | 6 +- crates/test-util/src/matchers.rs | 12 +- crates/types/Cargo.toml | 6 +- crates/types/build.rs | 4 +- crates/types/src/lib.rs | 3 - crates/worker/Cargo.toml | 2 +- .../command_interpreter/tests.rs | 2 +- tools/mock-service-endpoint/Cargo.toml | 2 +- tools/mock-service-endpoint/src/main.rs | 2 +- tools/restatectl/Cargo.toml | 5 +- .../src/commands/dump/cluster_state.rs | 4 +- tools/restatectl/src/util.rs | 16 +- tools/xtask/Cargo.toml | 2 +- tools/xtask/src/main.rs | 2 +- 62 files changed, 288 insertions(+), 441 deletions(-) delete mode 100644 crates/core/src/network/grpc_util.rs rename crates/{metadata-store/src/local/grpc => core/src/network}/net_util.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 37bdf1cb2..f17ceb2cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1092,8 +1092,6 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "serde_json", - "serde_path_to_error", "serde_urlencoded", "sync_wrapper 0.1.2", "tokio", @@ -3973,7 +3971,7 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-util", - "prost 0.12.3", + "prost 0.13.1", "restate-service-protocol", "restate-types", "serde", @@ -4909,28 +4907,6 @@ dependencies = [ "prost-derive 0.13.1", ] -[[package]] -name = "prost-build" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" -dependencies = [ - "bytes", - "heck 0.4.1", - "itertools 0.11.0", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost 0.12.3", - "prost-types 0.12.3", - "regex", - "syn 2.0.65", - "tempfile", - "which", -] - [[package]] name = "prost-build" version = "0.13.1" @@ -5407,9 +5383,9 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "okapi-operation", - "prost 0.12.3", + "prost 0.13.1", "prost-dto", - "prost-types 0.12.3", + "prost-types 0.13.1", "restate-admin-rest-model", "restate-bifrost", "restate-core", @@ -5431,7 +5407,8 @@ dependencies = [ "thiserror", "tokio", "tonic 0.10.2", - "tonic-build 0.11.0", + "tonic 0.12.1", + "tonic-build", "tower", "tracing", "tracing-subscriber", @@ -5632,15 +5609,15 @@ dependencies = [ "futures", "googletest", "hostname", - "http 0.2.12", + "http 1.1.0", "humantime", - "hyper 0.14.30", "hyper 1.4.1", + "hyper-util", "metrics 0.23.0", "once_cell", "pin-project", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.13.1", + "prost-types 0.13.1", "rand", "restate-test-util", "restate-types", @@ -5654,8 +5631,8 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "tonic 0.10.2", - "tonic-build 0.11.0", + "tonic 0.12.1", + "tonic-build", "tower", "tracing", "tracing-subscriber", @@ -5827,7 +5804,7 @@ dependencies = [ "opentelemetry", "opentelemetry-http", "opentelemetry_sdk", - "prost 0.12.3", + "prost 0.13.1", "restate-core", "restate-errors", "restate-fs-util", @@ -5930,9 +5907,9 @@ dependencies = [ "tokio-stream", "tokio-util", "tonic 0.12.1", - "tonic-build 0.12.1", + "tonic-build", "tonic-health", - "tonic-reflection 0.12.1", + "tonic-reflection", "tower", "tower-http 0.5.2", "tracing", @@ -5947,7 +5924,7 @@ dependencies = [ "arc-swap", "arrow-flight", "async-trait", - "axum 0.6.20", + "axum 0.7.5", "bytes", "codederror", "datafusion", @@ -5958,14 +5935,16 @@ dependencies = [ "futures", "googletest", "http 1.1.0", + "http-body 1.0.1", "humantime", - "hyper 0.14.30", + "hyper 1.4.1", + "hyper-util", "metrics 0.23.0", "metrics-exporter-prometheus", "metrics-tracing-context 0.16.0", "metrics-util 0.17.0", "once_cell", - "prost-types 0.12.3", + "prost-types 0.13.1", "restate-admin", "restate-bifrost", "restate-core", @@ -5993,9 +5972,10 @@ dependencies = [ "tokio-stream", "tokio-util", "tonic 0.10.2", - "tonic-reflection 0.10.2", + "tonic 0.12.1", + "tonic-reflection", "tower", - "tower-http 0.4.4", + "tower-http 0.5.2", "tracing", "tracing-subscriber", ] @@ -6018,7 +5998,7 @@ dependencies = [ "num-bigint", "once_cell", "paste", - "prost 0.12.3", + "prost 0.13.1", "rand", "restate-core", "restate-errors", @@ -6095,7 +6075,7 @@ dependencies = [ "http-serde", "humantime", "iso8601", - "prost 0.12.3", + "prost 0.13.1", "schemars", "serde", "serde_json", @@ -6200,7 +6180,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "paste", - "prost 0.12.3", + "prost 0.13.1", "regress 0.10.0", "restate-base64-util", "restate-errors", @@ -6229,9 +6209,9 @@ dependencies = [ "derive_more", "futures-util", "opentelemetry", - "prost 0.12.3", - "prost-build 0.12.3", - "prost-types 0.12.3", + "prost 0.13.1", + "prost-build", + "prost-types 0.13.1", "restate-types", "serde", "strum 0.26.2", @@ -6254,7 +6234,7 @@ dependencies = [ "futures", "googletest", "paste", - "prost 0.12.3", + "prost 0.13.1", "restate-core", "restate-invoker-api", "restate-partition-store", @@ -6285,7 +6265,7 @@ dependencies = [ "futures", "paste", "pgwire", - "prost 0.12.3", + "prost 0.13.1", "restate-core", "restate-errors", "restate-partition-store", @@ -6307,8 +6287,8 @@ dependencies = [ "assert2", "googletest", "pretty_assertions", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.13.1", + "prost-types 0.13.1", ] [[package]] @@ -6392,10 +6372,10 @@ dependencies = [ "once_cell", "opentelemetry", "prettyplease", - "prost 0.12.3", - "prost-build 0.12.3", + "prost 0.13.1", + "prost-build", "prost-dto", - "prost-types 0.12.3", + "prost-types 0.13.1", "rand", "regress 0.10.0", "restate-base64-util", @@ -6474,7 +6454,7 @@ dependencies = [ "metrics 0.23.0", "opentelemetry", "pin-project", - "prost 0.12.3", + "prost 0.13.1", "rand", "restate-bifrost", "restate-core", @@ -6526,14 +6506,15 @@ dependencies = [ "cling", "crossterm 0.27.0", "ctrlc", - "prost-types 0.12.3", + "hyper-util", + "prost-types 0.13.1", "restate-admin", "restate-cli-util", "restate-types", "thiserror", "tokio", "tokio-stream", - "tonic 0.10.2", + "tonic 0.12.1", "tower", "tracing", "tracing-log", @@ -7671,7 +7652,6 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "flate2", "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", @@ -7726,6 +7706,7 @@ dependencies = [ "axum 0.7.5", "base64 0.22.0", "bytes", + "flate2", "h2 0.4.5", "http 1.1.0", "http-body 1.0.1", @@ -7745,19 +7726,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tonic-build" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build 0.12.3", - "quote", - "syn 2.0.65", -] - [[package]] name = "tonic-build" version = "0.12.1" @@ -7766,7 +7734,7 @@ checksum = "568392c5a2bd0020723e3f387891176aabafe36fd9fcd074ad309dfa0c8eb964" dependencies = [ "prettyplease", "proc-macro2", - "prost-build 0.13.1", + "prost-build", "quote", "syn 2.0.65", ] @@ -7784,19 +7752,6 @@ dependencies = [ "tonic 0.12.1", ] -[[package]] -name = "tonic-reflection" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa37c513df1339d197f4ba21d28c918b9ef1ac1768265f11ecb6b7f1cba1b76" -dependencies = [ - "prost 0.12.3", - "prost-types 0.12.3", - "tokio", - "tokio-stream", - "tonic 0.10.2", -] - [[package]] name = "tonic-reflection" version = "0.12.1" @@ -8608,7 +8563,7 @@ dependencies = [ "schemars", "serde_json", "tokio", - "tonic 0.10.2", + "tonic 0.12.1", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 44460de89..c5135e401 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,12 +122,9 @@ parking_lot = { version = "0.12" } paste = "1.0" pin-project = "1.0" prost = { version = "0.13.1" } -prost-0-12 = { package = "prost", version = "0.12.1" } prost-build = { version = "0.13.1" } -prost-build-0-12 = { package = "prost-build", version = "0.12.1" } prost-dto = { version = "0.0.2" } prost-types = { version = "0.13.1" } -prost-types-0-12 = { package = "prost-types", version = "0.12.1" } rand = "0.8.5" rayon = { version = "1.10" } regress = { version = "0.10" } @@ -158,11 +155,8 @@ tokio-util = { version = "0.7.10" } tonic = { version = "0.12.1", default-features = false } tonic-0-10 = { package = "tonic", version = "0.10.2", default-features = false } tonic-reflection = { version = "0.12.1" } -tonic-reflection-0-10 = { package = "tonic-reflection", version = "0.10.2" } tonic-health = { version = "0.12.1" } -tonic-health-0-10 = { package = "tonic-health", version = "0.10.2" } tonic-build = { version = "0.12.1" } -tonic-build-0-11 = { package = "tonic-build", version = "0.11.0" } tower = "0.4" tower-http = { version = "0.5.2", default-features = false } tracing = "0.1" diff --git a/crates/admin/Cargo.toml b/crates/admin/Cargo.toml index 64d592087..762bc4cc5 100644 --- a/crates/admin/Cargo.toml +++ b/crates/admin/Cargo.toml @@ -40,9 +40,9 @@ http = { workspace = true } http-body = { workspace = true } http-body-util = { workspace = true } okapi-operation = { version = "0.3.0-rc2", features = ["axum-integration"] } -prost-0-12 = { workspace = true } +prost = { workspace = true } prost-dto = { workspace = true } -prost-types-0-12 = { workspace = true } +prost-types = { workspace = true } restate-serde-util = { workspace = true, features = ["schema"] } schemars = { workspace = true } serde = { workspace = true } @@ -50,12 +50,13 @@ serde_json = { workspace = true } serde_with = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } -tonic-0-10 = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } +tonic = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } +tonic-0-10 = { workspace = true } tower = { workspace = true, features = ["load-shed", "limit"] } tracing = { workspace = true } [build-dependencies] -tonic-build-0-11 = { workspace = true } +tonic-build = { workspace = true } [dev-dependencies] restate-bifrost = { workspace = true, features = ["test-util"] } diff --git a/crates/admin/build.rs b/crates/admin/build.rs index 5f71248af..16702231e 100644 --- a/crates/admin/build.rs +++ b/crates/admin/build.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - tonic_build_0_11::configure() + tonic_build::configure() .bytes(["."]) .file_descriptor_set_path(out_dir.join("cluster_ctrl_svc_descriptor.bin")) .server_mod_attribute("cluster_ctrl", "#[cfg(feature = \"servers\")]") diff --git a/crates/admin/src/cluster_controller/protobuf.rs b/crates/admin/src/cluster_controller/protobuf.rs index cc917517d..8d5274e78 100644 --- a/crates/admin/src/cluster_controller/protobuf.rs +++ b/crates/admin/src/cluster_controller/protobuf.rs @@ -8,7 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -tonic_0_10::include_proto!("restate.cluster_ctrl"); +tonic::include_proto!("restate.cluster_ctrl"); pub const FILE_DESCRIPTOR_SET: &[u8] = - tonic_0_10::include_file_descriptor_set!("cluster_ctrl_svc_descriptor"); + tonic::include_file_descriptor_set!("cluster_ctrl_svc_descriptor"); diff --git a/crates/admin/src/lib.rs b/crates/admin/src/lib.rs index d9ed7fc44..1ba4442ed 100644 --- a/crates/admin/src/lib.rs +++ b/crates/admin/src/lib.rs @@ -8,9 +8,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -extern crate prost_0_12 as prost; -extern crate prost_types_0_12 as prost_types; -extern crate tonic_0_10 as tonic; pub mod cluster_controller; mod error; mod rest_api; diff --git a/crates/admin/src/service.rs b/crates/admin/src/service.rs index f0f50eeab..c44bf6ca7 100644 --- a/crates/admin/src/service.rs +++ b/crates/admin/src/service.rs @@ -15,7 +15,7 @@ use http::StatusCode; use restate_bifrost::Bifrost; use restate_types::config::AdminOptions; use restate_types::live::LiveLoad; -use tonic_0_10::transport::Channel; +use tonic::transport::Channel; use tower::ServiceBuilder; use tracing::info; diff --git a/crates/admin/src/state.rs b/crates/admin/src/state.rs index cb28e6f00..46df7ab18 100644 --- a/crates/admin/src/state.rs +++ b/crates/admin/src/state.rs @@ -13,7 +13,7 @@ use crate::schema_registry::SchemaRegistry; use restate_bifrost::Bifrost; use restate_core::network::protobuf::node_svc::node_svc_client::NodeSvcClient; use restate_core::TaskCenter; -use tonic_0_10::transport::Channel; +use tonic::transport::Channel; #[derive(Clone, derive_builder::Builder)] pub struct AdminServiceState { diff --git a/crates/admin/src/storage_query/error.rs b/crates/admin/src/storage_query/error.rs index 53e59544c..3ce25b690 100644 --- a/crates/admin/src/storage_query/error.rs +++ b/crates/admin/src/storage_query/error.rs @@ -24,7 +24,7 @@ use serde::Serialize; #[derive(Debug, thiserror::Error)] pub enum StorageQueryError { #[error("failed grpc: {0}")] - Tonic(#[from] tonic_0_10::Status), + Tonic(#[from] tonic::Status), } /// # Error description response diff --git a/crates/admin/src/storage_query/query.rs b/crates/admin/src/storage_query/query.rs index 8e0010296..2e9c46f03 100644 --- a/crates/admin/src/storage_query/query.rs +++ b/crates/admin/src/storage_query/query.rs @@ -9,6 +9,7 @@ // by the Apache License, Version 2.0. use std::pin::Pin; +use std::str::FromStr; use std::sync::Arc; use std::task::{Context, Poll}; @@ -31,11 +32,12 @@ use futures::{ready, Stream, StreamExt, TryStreamExt}; use http_body::Frame; use http_body_util::StreamBody; use okapi_operation::*; +use restate_core::network::protobuf::node_svc::StorageQueryRequest; use schemars::JsonSchema; use serde::Deserialize; use serde_with::serde_as; - -use restate_core::network::protobuf::node_svc::StorageQueryRequest; +use tonic::metadata::{KeyAndValueRef, MetadataMap}; +use tonic::Status; use super::error::StorageQueryError; use crate::state::QueryServiceState; @@ -79,7 +81,7 @@ pub async fn query( data_body: response.data, ..FlightData::default() }) - .map_err(FlightError::from), + .map_err(|status| FlightError::from(tonic_status_012_to_010(status))), ); // create a stream without LargeUtf8 or LargeBinary columns as JS doesn't support these yet @@ -268,3 +270,40 @@ impl Stream for ConvertRecordBatchStream { } } } + +// todo: Remove once arrow-flight works with tonic 0.12 +fn tonic_status_012_to_010(status: Status) -> tonic_0_10::Status { + let code = tonic_0_10::Code::from(status.code() as i32); + let message = status.message().to_owned(); + let details = Bytes::copy_from_slice(status.details()); + let metadata = tonic_metadata_map_012_to_010(status.metadata()); + tonic_0_10::Status::with_details_and_metadata(code, message, details, metadata) +} + +// todo: Remove once arrow-flight works with tonic 0.12 +fn tonic_metadata_map_012_to_010(metadata_map: &MetadataMap) -> tonic_0_10::metadata::MetadataMap { + let mut resulting_metadata_map = + tonic_0_10::metadata::MetadataMap::with_capacity(metadata_map.len()); + for key_value in metadata_map.iter() { + match key_value { + KeyAndValueRef::Ascii(key, value) => { + // ignore metadata map entries if conversion fails + if let Ok(value) = + tonic_0_10::metadata::MetadataValue::from_str(value.to_str().unwrap_or("")) + { + if let Ok(key) = tonic_0_10::metadata::MetadataKey::from_str(key.as_str()) { + resulting_metadata_map.insert(key, value); + } + } + } + KeyAndValueRef::Binary(key, value) => { + if let Ok(key) = tonic_0_10::metadata::MetadataKey::from_bytes(key.as_ref()) { + let value = tonic_0_10::metadata::MetadataValue::from_bytes(value.as_ref()); + resulting_metadata_map.insert_bin(key, value); + } + } + } + } + + resulting_metadata_map +} diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index fa669e7f8..b0cdd1216 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -27,15 +27,15 @@ enum-map = { workspace = true } enumset = { workspace = true } futures = { workspace = true } hostname = { workspace = true } -http_0_2 = { package = "http", version = "0.2" } -hyper_0_14 = { package = "hyper", version = "0.14" } +http = { workspace = true } humantime = { workspace = true } hyper = { workspace = true } +hyper-util = { workspace = true } metrics = { workspace = true } once_cell = { workspace = true } pin-project = { workspace = true } -prost-0-12 = { workspace = true } -prost-types-0-12 = { workspace = true } +prost = { workspace = true } +prost-types = { workspace = true } rand = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } @@ -47,12 +47,12 @@ thiserror = { workspace = true } tokio = { workspace = true, features = ["tracing"] } tokio-stream = { workspace = true, features = ["net"] } tokio-util = { workspace = true } -tonic-0-10 = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } +tonic = { workspace = true, features = ["transport", "codegen", "prost", "gzip"] } tower = { workspace = true } tracing = { workspace = true } [build-dependencies] -tonic-build-0-11 = { workspace = true } +tonic-build = { workspace = true } [dev-dependencies] restate-test-util = { workspace = true } diff --git a/crates/core/build.rs b/crates/core/build.rs index 100ae60a0..abf617581 100644 --- a/crates/core/build.rs +++ b/crates/core/build.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; fn main() -> Result<(), Box> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - tonic_build_0_11::configure() + tonic_build::configure() .bytes(["."]) .file_descriptor_set_path(out_dir.join("node_svc_descriptor.bin")) // allow older protobuf compiler to be used diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index b054de2d7..7e443aa1c 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -8,10 +8,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -extern crate prost_0_12 as prost; -extern crate prost_types_0_12 as prost_types; -extern crate tonic_0_10 as tonic; - mod metadata; pub mod metadata_store; mod metric_definitions; diff --git a/crates/core/src/network/connection_manager.rs b/crates/core/src/network/connection_manager.rs index c198ebab9..426b81919 100644 --- a/crates/core/src/network/connection_manager.rs +++ b/crates/core/src/network/connection_manager.rs @@ -18,7 +18,7 @@ use rand::seq::SliceRandom; use restate_types::net::codec::try_unwrap_binary_message; use tokio::sync::mpsc; use tokio_stream::wrappers::ReceiverStream; -use tonic_0_10::transport::Channel; +use tonic::transport::Channel; use tracing::{debug, info, trace, warn, Instrument, Span}; use restate_types::live::Pinned; @@ -31,7 +31,6 @@ use restate_types::{GenerationalNodeId, NodeId, PlainNodeId}; use super::connection::{Connection, ConnectionSender}; use super::error::{NetworkError, ProtocolError}; -use super::grpc_util::create_grpc_channel_from_advertised_address; use super::handshake::{negotiate_protocol_version, wait_for_hello, wait_for_welcome}; use super::metric_definitions::{ self, CONNECTION_DROPPED, INCOMING_CONNECTION, MESSAGE_PROCESSING_DURATION, MESSAGE_RECEIVED, @@ -39,6 +38,7 @@ use super::metric_definitions::{ }; use super::protobuf::node_svc::node_svc_client::NodeSvcClient; use super::{Handler, MessageRouter}; +use crate::network::net_util::create_tonic_channel_from_advertised_address; use crate::{cancellation_watcher, current_task_id, task_center, TaskId, TaskKind}; use crate::{Metadata, TargetVersion}; @@ -112,7 +112,7 @@ impl ConnectionManager { pub async fn accept_incoming_connection( &self, mut incoming: S, - ) -> Result>, NetworkError> + ) -> Result>, NetworkError> where S: Stream> + Unpin + Send + 'static, { @@ -142,12 +142,9 @@ impl ConnectionManager { let nodes_config = self.metadata.nodes_config_ref(); let my_node_id = self.metadata.my_node_id(); // NodeId **must** be generational at this layer - let peer_node_id = hello - .my_node_id - .clone() - .ok_or(ProtocolError::HandshakeFailed( - "NodeId is not set in the Hello message", - ))?; + let peer_node_id = hello.my_node_id.ok_or(ProtocolError::HandshakeFailed( + "NodeId is not set in the Hello message", + ))?; if peer_node_id.generation() == 0 { return Err( @@ -230,7 +227,7 @@ impl ConnectionManager { self.metadata .sync( MetadataKind::NodesConfiguration, - TargetVersion::from(header.my_nodes_config_version.clone().map(Into::into)), + TargetVersion::from(header.my_nodes_config_version.map(Into::into)), ) .await?; nodes_config = self.metadata.nodes_config_ref(); @@ -291,7 +288,7 @@ impl ConnectionManager { let channel = { let mut guard = self.inner.lock().unwrap(); if let hash_map::Entry::Vacant(entry) = guard.channel_cache.entry(address.clone()) { - let channel = create_grpc_channel_from_advertised_address(address) + let channel = create_tonic_channel_from_advertised_address(address) .map_err(|e| NetworkError::BadNodeAddress(node_id.into(), e))?; entry.insert(channel.clone()); channel diff --git a/crates/core/src/network/error.rs b/crates/core/src/network/error.rs index 99b676dd9..b4fb689ae 100644 --- a/crates/core/src/network/error.rs +++ b/crates/core/src/network/error.rs @@ -29,13 +29,13 @@ pub enum NetworkError { #[error("operation aborted, node is shutting down")] Shutdown(#[from] ShutdownError), #[error("node {0} address is bad: {1}")] - BadNodeAddress(NodeId, http_0_2::Error), + BadNodeAddress(NodeId, http::Error), #[error("timeout: {0}")] Timeout(&'static str), #[error("protocol error: {0}")] ProtocolError(#[from] ProtocolError), - #[error("cannot connect: {} {}", tonic_0_10::Status::code(.0), tonic_0_10::Status::message(.0))] - ConnectError(#[from] tonic_0_10::Status), + #[error("cannot connect: {} {}", tonic::Status::code(.0), tonic::Status::message(.0))] + ConnectError(#[from] tonic::Status), #[error("new node generation exists: {0}")] OldPeerGeneration(String), #[error("peer is not connected")] @@ -57,7 +57,7 @@ pub enum ProtocolError { #[error("codec error: {0}")] Codec(#[from] CodecError), #[error("grpc error: {0}")] - GrpcError(#[from] tonic_0_10::Status), + GrpcError(#[from] tonic::Status), #[error( "peer has unsupported protocol version {0}, minimum supported is '{}'", MIN_SUPPORTED_PROTOCOL_VERSION as i32 @@ -65,30 +65,30 @@ pub enum ProtocolError { UnsupportedVersion(i32), } -impl From for tonic_0_10::Status { +impl From for tonic::Status { fn from(value: ProtocolError) -> Self { match value { - ProtocolError::HandshakeFailed(e) => tonic_0_10::Status::invalid_argument(e), - ProtocolError::HandshakeTimeout(e) => tonic_0_10::Status::deadline_exceeded(e), - ProtocolError::PeerDropped => tonic_0_10::Status::cancelled("peer dropped"), - ProtocolError::Codec(e) => tonic_0_10::Status::internal(e.to_string()), + ProtocolError::HandshakeFailed(e) => tonic::Status::invalid_argument(e), + ProtocolError::HandshakeTimeout(e) => tonic::Status::deadline_exceeded(e), + ProtocolError::PeerDropped => tonic::Status::cancelled("peer dropped"), + ProtocolError::Codec(e) => tonic::Status::internal(e.to_string()), ProtocolError::UnsupportedVersion(_) => { - tonic_0_10::Status::invalid_argument(value.to_string()) + tonic::Status::invalid_argument(value.to_string()) } ProtocolError::GrpcError(s) => s, } } } -impl From for tonic_0_10::Status { +impl From for tonic::Status { fn from(value: NetworkError) -> Self { match value { - NetworkError::Shutdown(_) => tonic_0_10::Status::unavailable(value.to_string()), + NetworkError::Shutdown(_) => tonic::Status::unavailable(value.to_string()), NetworkError::ProtocolError(e) => e.into(), - NetworkError::Timeout(e) => tonic_0_10::Status::deadline_exceeded(e), - NetworkError::OldPeerGeneration(e) => tonic_0_10::Status::already_exists(e), + NetworkError::Timeout(e) => tonic::Status::deadline_exceeded(e), + NetworkError::OldPeerGeneration(e) => tonic::Status::already_exists(e), NetworkError::ConnectError(s) => s, - e => tonic_0_10::Status::internal(e.to_string()), + e => tonic::Status::internal(e.to_string()), } } } diff --git a/crates/core/src/network/grpc_util.rs b/crates/core/src/network/grpc_util.rs deleted file mode 100644 index 472f7c648..000000000 --- a/crates/core/src/network/grpc_util.rs +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH. -// All rights reserved. -// -// Use of this software is governed by the Business Source License -// included in the LICENSE file. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0. - -use std::future::Future; -use std::net::SocketAddr; -use std::path::PathBuf; -use std::time::Duration; - -use hyper_0_14::body::HttpBody; -use hyper_0_14::http::Uri; -use hyper_0_14::server::accept::Accept; -use hyper_0_14::server::conn::AddrIncoming; -use restate_types::net::{AdvertisedAddress, BindAddress}; -use tokio::io; -use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::net::{UnixListener, UnixStream}; -use tokio_stream::wrappers::UnixListenerStream; -use tonic_0_10::transport::{Channel, Endpoint}; -use tracing::{debug, info}; - -pub fn create_grpc_channel_from_advertised_address( - address: AdvertisedAddress, -) -> Result { - let channel = match address { - AdvertisedAddress::Uds(uds_path) => { - // dummy endpoint required to specify an uds connector, it is not used anywhere - Endpoint::try_from("http://127.0.0.1") - .expect("/ should be a valid Uri") - .connect_with_connector_lazy(tower::service_fn(move |_: Uri| { - UnixStream::connect(uds_path.clone()) - })) - } - AdvertisedAddress::Http(uri) => { - // todo: Make the channel settings configurable - Channel::builder( - // TODO we need this because we use a old tonic version that still uses old http types. We can remove this once tonic bumps to 1.0 - uri.to_string() - .parse() - .expect("uri conversion should work fine"), - ) - .connect_timeout(Duration::from_secs(5)) - // todo: configure the channel from configuration file - .http2_adaptive_window(true) - .connect_lazy() - } - }; - Ok(channel) -} - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("failed binding to address '{address}': {source}")] - TcpBinding { - address: SocketAddr, - #[source] - source: hyper_0_14::Error, - }, - #[error("failed opening uds '{uds_path}': {source}")] - UdsBinding { - uds_path: PathBuf, - #[source] - source: io::Error, - }, - #[error("failed running grpc server: {0}")] - Running(#[from] hyper_0_14::Error), -} - -pub async fn run_hyper_server( - bind_address: &BindAddress, - service: S, - shutdown_signal: F, - server_name: &str, -) -> Result<(), Error> -where - S: hyper_0_14::service::Service< - http_0_2::Request, - Response = hyper_0_14::Response, - > + Send - + Clone - + 'static, - S::Error: Into>, - S::Future: Send, - B: HttpBody + Send + 'static, - B::Data: Send, - B::Error: Into>, - F: Future, -{ - match bind_address { - BindAddress::Uds(uds_path) => { - let unix_listener = UnixListener::bind(uds_path).map_err(|err| Error::UdsBinding { - uds_path: uds_path.clone(), - source: err, - })?; - let acceptor = - hyper_0_14::server::accept::from_stream(UnixListenerStream::new(unix_listener)); - - info!(uds.path = %uds_path.display(), "Server '{}' listening", server_name); - - run_server(acceptor, service, shutdown_signal).await? - } - BindAddress::Socket(socket_addr) => { - run_tcp_server(socket_addr, service, shutdown_signal, server_name).await? - } - } - - debug!("Stopped server '{}'", server_name); - - Ok(()) -} - -async fn run_tcp_server( - socket_addr: &SocketAddr, - service: S, - shutdown_signal: F, - server_name: &str, -) -> Result<(), Error> -where - S: hyper_0_14::service::Service< - http_0_2::Request, - Response = hyper_0_14::Response, - > + Send - + Clone - + 'static, - S::Error: Into>, - S::Future: Send, - B: HttpBody + Send + 'static, - B::Data: Send, - B::Error: Into>, - F: Future, -{ - let acceptor = AddrIncoming::bind(socket_addr).map_err(|err| Error::TcpBinding { - address: *socket_addr, - source: err, - })?; - - info!( - net.host.addr = %acceptor.local_addr().ip(), - net.host.port = %acceptor.local_addr().port(), - "Server '{}' listening", server_name - ); - - run_server(acceptor, service, shutdown_signal).await -} - -async fn run_server( - acceptor: impl Accept, - service: S, - shutdown_signal: F, -) -> Result<(), Error> -where - S: hyper_0_14::service::Service< - http_0_2::Request, - Response = hyper_0_14::Response, - > + Send - + Clone - + 'static, - S::Error: Into>, - S::Future: Send, - B: HttpBody + Send + 'static, - B::Data: Send, - B::Error: Into>, - Conn: AsyncRead + AsyncWrite + Unpin + Send + 'static, - Err: Into>, - F: Future, -{ - let server = hyper_0_14::Server::builder(acceptor).serve(tower::make::Shared::new(service)); - - server - .with_graceful_shutdown(shutdown_signal) - .await - .map_err(Error::Running) -} diff --git a/crates/core/src/network/mod.rs b/crates/core/src/network/mod.rs index fdcfa438d..6c6278bd2 100644 --- a/crates/core/src/network/mod.rs +++ b/crates/core/src/network/mod.rs @@ -11,10 +11,10 @@ mod connection; mod connection_manager; mod error; -pub mod grpc_util; mod handshake; mod message_router; pub(crate) mod metric_definitions; +pub mod net_util; mod network_sender; mod networking; pub mod protobuf; diff --git a/crates/metadata-store/src/local/grpc/net_util.rs b/crates/core/src/network/net_util.rs similarity index 98% rename from crates/metadata-store/src/local/grpc/net_util.rs rename to crates/core/src/network/net_util.rs index fb7ced286..0c01574e6 100644 --- a/crates/metadata-store/src/local/grpc/net_util.rs +++ b/crates/core/src/network/net_util.rs @@ -8,11 +8,11 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +use crate::{cancellation_watcher, task_center, ShutdownError, TaskCenter, TaskKind}; use http::Uri; use hyper::body::{Body, Incoming}; use hyper::rt::{Read, Write}; use hyper_util::rt::TokioIo; -use restate_core::{cancellation_watcher, task_center, ShutdownError, TaskCenter, TaskKind}; use restate_types::errors::GenericError; use restate_types::net::{AdvertisedAddress, BindAddress}; use std::fmt::Debug; diff --git a/crates/core/src/network/protobuf.rs b/crates/core/src/network/protobuf.rs index 174d691b1..458a5558e 100644 --- a/crates/core/src/network/protobuf.rs +++ b/crates/core/src/network/protobuf.rs @@ -9,8 +9,8 @@ // by the Apache License, Version 2.0. pub mod node_svc { - tonic_0_10::include_proto!("restate.node_svc"); + tonic::include_proto!("restate.node_svc"); pub const FILE_DESCRIPTOR_SET: &[u8] = - tonic_0_10::include_file_descriptor_set!("node_svc_descriptor"); + tonic::include_file_descriptor_set!("node_svc_descriptor"); } diff --git a/crates/invoker-impl/Cargo.toml b/crates/invoker-impl/Cargo.toml index 37fa5fe46..35e8ab2e9 100644 --- a/crates/invoker-impl/Cargo.toml +++ b/crates/invoker-impl/Cargo.toml @@ -56,7 +56,7 @@ restate-test-util = { workspace = true } restate-types = { workspace = true } googletest = { workspace = true } -prost-0-12 = { workspace = true } +prost = { workspace = true } tempfile = { workspace = true } test-log = { workspace = true } tokio-util = { workspace = true } diff --git a/crates/metadata-store/src/local/grpc/client.rs b/crates/metadata-store/src/local/grpc/client.rs index 196a12de8..601be26e9 100644 --- a/crates/metadata-store/src/local/grpc/client.rs +++ b/crates/metadata-store/src/local/grpc/client.rs @@ -16,12 +16,12 @@ use tonic::{Code, Status}; use restate_core::metadata_store::{ MetadataStore, Precondition, ReadError, VersionedValue, WriteError, }; +use restate_core::network::net_util::create_tonic_channel_from_advertised_address; use restate_types::net::AdvertisedAddress; use restate_types::Version; use crate::grpc_svc::metadata_store_svc_client::MetadataStoreSvcClient; use crate::grpc_svc::{DeleteRequest, GetRequest, PutRequest}; -use crate::local::grpc::net_util::create_tonic_channel_from_advertised_address; use crate::local::grpc::pb_conversions::ConversionError; /// Client end to interact with the [`LocalMetadataStore`]. diff --git a/crates/metadata-store/src/local/grpc/mod.rs b/crates/metadata-store/src/local/grpc/mod.rs index 47e4ff962..6d34ffad7 100644 --- a/crates/metadata-store/src/local/grpc/mod.rs +++ b/crates/metadata-store/src/local/grpc/mod.rs @@ -10,7 +10,6 @@ pub mod client; pub mod handler; -pub mod net_util; pub mod pb_conversions { use crate::grpc_svc; diff --git a/crates/metadata-store/src/local/service.rs b/crates/metadata-store/src/local/service.rs index 07a2f8075..f0f4d9444 100644 --- a/crates/metadata-store/src/local/service.rs +++ b/crates/metadata-store/src/local/service.rs @@ -8,9 +8,14 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +use crate::grpc_svc; +use crate::grpc_svc::metadata_store_svc_server::MetadataStoreSvcServer; +use crate::local::grpc::handler::LocalMetadataStoreHandler; +use crate::local::store::LocalMetadataStore; use http::Request; use hyper::body::Incoming; use hyper_util::service::TowerToHyperService; +use restate_core::network::net_util; use restate_core::{task_center, ShutdownError, TaskKind}; use restate_rocksdb::RocksError; use restate_types::config::{MetadataStoreOptions, RocksDbOptions}; @@ -19,12 +24,6 @@ use tonic::body::boxed; use tonic::server::NamedService; use tower::ServiceExt; -use crate::grpc_svc; -use crate::grpc_svc::metadata_store_svc_server::MetadataStoreSvcServer; -use crate::local::grpc::handler::LocalMetadataStoreHandler; -use crate::local::grpc::net_util; -use crate::local::store::LocalMetadataStore; - pub struct LocalMetadataStoreService { opts: BoxedLiveLoad, rocksdb_options: BoxedLiveLoad, diff --git a/crates/metadata-store/src/local/tests.rs b/crates/metadata-store/src/local/tests.rs index 8de795448..c532feb2e 100644 --- a/crates/metadata-store/src/local/tests.rs +++ b/crates/metadata-store/src/local/tests.rs @@ -18,6 +18,7 @@ use test_log::test; use tonic_health::pb::health_client::HealthClient; use tonic_health::pb::HealthCheckRequest; +use restate_core::network::net_util::create_tonic_channel_from_advertised_address; use restate_core::{MockNetworkSender, TaskCenter, TaskKind, TestCoreEnv, TestCoreEnvBuilder}; use restate_rocksdb::RocksDbManager; use restate_types::config::{ @@ -29,7 +30,6 @@ use restate_types::retries::RetryPolicy; use restate_types::{flexbuffers_storage_encode_decode, Version, Versioned}; use crate::local::grpc::client::LocalMetadataStoreClient; -use crate::local::grpc::net_util::create_tonic_channel_from_advertised_address; use crate::local::service::LocalMetadataStoreService; use crate::{MetadataStoreClient, Precondition, WriteError}; diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index a4de37ec1..359d3cfbd 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -34,7 +34,7 @@ anyhow = { workspace = true } arc-swap = { workspace = true } arrow-flight = { workspace = true } async-trait = { workspace = true } -axum-0-6 = { package = "axum", version = "0.6" } +axum = { workspace = true } bytes = { workspace = true } codederror = { workspace = true } datafusion = { workspace = true } @@ -44,14 +44,16 @@ enum-map = { workspace = true } enumset = { workspace = true } futures = { workspace = true } http = { workspace = true } +http-body = { workspace = true } humantime = { workspace = true } -hyper-0-14 = { package = "hyper", version = "0.14", features = ["full"] } +hyper = { workspace = true, features = ["full"] } +hyper-util = { workspace = true } metrics = { workspace = true } metrics-exporter-prometheus = { workspace = true } metrics-tracing-context = { version = "0.16.0" } metrics-util = { version = "0.17.0" } once_cell = { workspace = true } -prost-types-0-12 = { workspace = true } +prost-types = { workspace = true } rocksdb = { workspace = true } schemars = { workspace = true, optional = true } semver = { version = "1.0", features = ["serde"] } @@ -64,10 +66,11 @@ thiserror = { workspace = true } tokio = { workspace = true } tokio-stream = { workspace = true } tokio-util = { workspace = true } +tonic = { workspace = true } tonic-0-10 = { workspace = true } -tonic-reflection-0-10 = { workspace = true } +tonic-reflection = { workspace = true } tower = { workspace = true } -tower-http-0-4 = { package = "tower-http", version = "0.4", features = ["trace"] } +tower-http = { workspace = true, features = ["trace"] } tracing = { workspace = true } [dev-dependencies] diff --git a/crates/node/src/network_server/handler/cluster_ctrl.rs b/crates/node/src/network_server/handler/cluster_ctrl.rs index c57767543..70d037538 100644 --- a/crates/node/src/network_server/handler/cluster_ctrl.rs +++ b/crates/node/src/network_server/handler/cluster_ctrl.rs @@ -8,7 +8,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use tonic_0_10::{async_trait, Request, Response, Status}; +use tonic::{async_trait, Request, Response, Status}; use tracing::info; use restate_admin::cluster_controller::protobuf::cluster_ctrl_svc_server::ClusterCtrlSvc; @@ -45,7 +45,7 @@ impl ClusterCtrlSvc for ClusterCtrlSvcHandler { .controller_handle .get_cluster_state() .await - .map_err(|_| tonic_0_10::Status::aborted("Node is shutting down"))?; + .map_err(|_| tonic::Status::aborted("Node is shutting down"))?; let resp = ClusterStateResponse { cluster_state: Some((*cluster_state).clone().into()), diff --git a/crates/node/src/network_server/handler/mod.rs b/crates/node/src/network_server/handler/mod.rs index 91355eba2..42ec658aa 100644 --- a/crates/node/src/network_server/handler/mod.rs +++ b/crates/node/src/network_server/handler/mod.rs @@ -13,7 +13,7 @@ pub mod node; use std::fmt::Write; -use axum_0_6::extract::State; +use axum::extract::State; use metrics_exporter_prometheus::formatting; use rocksdb::statistics::{Histogram, Ticker}; diff --git a/crates/node/src/network_server/handler/node.rs b/crates/node/src/network_server/handler/node.rs index f8a030792..9c232994f 100644 --- a/crates/node/src/network_server/handler/node.rs +++ b/crates/node/src/network_server/handler/node.rs @@ -10,11 +10,9 @@ use arrow_flight::encode::FlightDataEncoderBuilder; use arrow_flight::error::FlightError; +use bytes::Bytes; use futures::stream::BoxStream; use futures::TryStreamExt; -use tokio_stream::StreamExt; -use tonic_0_10::{Request, Response, Status, Streaming}; - use restate_core::network::protobuf::node_svc::node_svc_server::NodeSvc; use restate_core::network::protobuf::node_svc::IdentResponse; use restate_core::network::protobuf::node_svc::{StorageQueryRequest, StorageQueryResponse}; @@ -23,6 +21,10 @@ use restate_core::network::ProtocolError; use restate_core::{metadata, TaskCenter}; use restate_types::protobuf::common::NodeStatus; use restate_types::protobuf::node::Message; +use std::str::FromStr; +use tokio_stream::StreamExt; +use tonic::metadata::{MetadataKey, MetadataMap, MetadataValue}; +use tonic::{Code, Request, Response, Status, Streaming}; use crate::network_server::WorkerDependencies; @@ -90,7 +92,7 @@ impl NodeSvc for NodeSvcHandler { header: flight_data.data_header, data: flight_data.data_body, }) - .map_err(Status::from); + .map_err(flight_error_to_tonic_status); Ok(Response::new(Box::pin(response_stream))) } @@ -122,3 +124,49 @@ impl NodeSvc for NodeSvcHandler { Ok(Response::new(output_stream)) } } + +// todo: Remove once arrow-flight supports tonic 0.12 +fn flight_error_to_tonic_status(err: FlightError) -> Status { + match err { + FlightError::Arrow(e) => Status::internal(e.to_string()), + FlightError::NotYetImplemented(e) => Status::internal(e), + FlightError::Tonic(status) => tonic_status_010_to_012(status), + FlightError::ProtocolError(e) => Status::internal(e), + FlightError::DecodeError(e) => Status::internal(e), + FlightError::ExternalError(e) => Status::internal(e.to_string()), + } +} + +// todo: Remove once arrow-flight works with tonic 0.12 +fn tonic_status_010_to_012(status: tonic_0_10::Status) -> Status { + let code = Code::from(status.code() as i32); + let message = status.message().to_owned(); + let details = Bytes::copy_from_slice(status.details()); + let metadata = tonic_metadata_map_010_to_012(status.metadata()); + Status::with_details_and_metadata(code, message, details, metadata) +} + +// todo: Remove once arrow-flight works with tonic 0.12 +fn tonic_metadata_map_010_to_012(metadata_map: &tonic_0_10::metadata::MetadataMap) -> MetadataMap { + let mut resulting_metadata_map = MetadataMap::with_capacity(metadata_map.len()); + for key_value in metadata_map.iter() { + match key_value { + tonic_0_10::metadata::KeyAndValueRef::Ascii(key, value) => { + // ignore metadata map entries if conversion fails + if let Ok(value) = MetadataValue::from_str(value.to_str().unwrap_or("")) { + if let Ok(key) = MetadataKey::from_str(key.as_str()) { + resulting_metadata_map.insert(key, value); + } + } + } + tonic_0_10::metadata::KeyAndValueRef::Binary(key, value) => { + if let Ok(key) = MetadataKey::from_bytes(key.as_ref()) { + let value = MetadataValue::from_bytes(value.as_ref()); + resulting_metadata_map.insert_bin(key, value); + } + } + } + } + + resulting_metadata_map +} diff --git a/crates/node/src/network_server/multiplex.rs b/crates/node/src/network_server/multiplex.rs index 079261e5c..5832e8ef8 100644 --- a/crates/node/src/network_server/multiplex.rs +++ b/crates/node/src/network_server/multiplex.rs @@ -13,12 +13,12 @@ //! Mostly copied from axum example: https://github.com/tokio-rs/axum/blob/791d5038a927add3f8ff1d5c1010cd0b24fdda77/examples/rest-grpc-multiplex/src/multiplex_service.rs //! License MIT -use axum_0_6::{ +use axum::{ http::header::CONTENT_TYPE, response::{IntoResponse, Response}, }; use futures::{future::BoxFuture, ready}; -use hyper_0_14::Request; +use hyper::Request; use std::{ convert::Infallible, task::{Context, Poll}, @@ -59,14 +59,15 @@ where } } -impl Service> for MultiplexService +impl Service> for MultiplexService where - A: Service, Error = Infallible>, + A: Service, Error = Infallible>, A::Response: IntoResponse, A::Future: Send + 'static, - B: Service>, + B: Service>, B::Response: IntoResponse, B::Future: Send + 'static, + R: http_body::Body + Send + 'static, { type Response = Response; type Error = B::Error; @@ -91,7 +92,7 @@ where } } - fn call(&mut self, req: Request) -> Self::Future { + fn call(&mut self, req: Request) -> Self::Future { // require users to call `poll_ready` first, if they don't we're allowed to panic // as per the `tower::Service` contract assert!( diff --git a/crates/node/src/network_server/service.rs b/crates/node/src/network_server/service.rs index ca4a3fc28..64959a8f7 100644 --- a/crates/node/src/network_server/service.rs +++ b/crates/node/src/network_server/service.rs @@ -8,16 +8,21 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use axum_0_6::routing::get; -use tonic_0_10::codec::CompressionEncoding; -use tower_http_0_4::trace::TraceLayer; +use axum::routing::get; +use http::Request; +use hyper::body::Incoming; +use hyper_util::service::TowerToHyperService; +use tonic::body::boxed; +use tonic::codec::CompressionEncoding; +use tower::ServiceExt; +use tower_http::trace::TraceLayer; use restate_admin::cluster_controller::protobuf::cluster_ctrl_svc_server::ClusterCtrlSvcServer; use restate_admin::cluster_controller::ClusterControllerHandle; -use restate_core::network::grpc_util::run_hyper_server; +use restate_core::network::net_util::run_hyper_server; use restate_core::network::protobuf::node_svc::node_svc_server::NodeSvcServer; use restate_core::network::ConnectionManager; -use restate_core::{cancellation_watcher, task_center}; +use restate_core::task_center; use restate_metadata_store::MetadataStoreClient; use restate_storage_query_datafusion::context::QueryContext; use restate_types::config::CommonOptions; @@ -61,19 +66,19 @@ impl NetworkServer { let shared_state = state_builder.build().expect("should be infallible"); // Trace layer - let span_factory = tower_http_0_4::trace::DefaultMakeSpan::new() + let span_factory = tower_http::trace::DefaultMakeSpan::new() .include_headers(true) .level(tracing::Level::ERROR); // -- HTTP service (for prometheus et al.) - let router = axum_0_6::Router::new() + let router = axum::Router::new() .route("/metrics", get(handler::render_metrics)) .with_state(shared_state) .layer(TraceLayer::new_for_http().make_span_with(span_factory.clone())) .fallback(handler_404); // -- GRPC Service Setup - let mut reflection_service_builder = tonic_reflection_0_10::server::Builder::configure() + let mut reflection_service_builder = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set( restate_core::network::protobuf::node_svc::FILE_DESCRIPTOR_SET, ) @@ -92,7 +97,7 @@ impl NetworkServer { .send_compressed(CompressionEncoding::Gzip) }); - let server_builder = tonic_0_10::transport::Server::builder() + let server_builder = tonic::transport::Server::builder() .layer(TraceLayer::new_for_grpc().make_span_with(span_factory)) .add_service( NodeSvcServer::new(NodeSvcHandler::new( @@ -107,24 +112,21 @@ impl NetworkServer { .add_service(reflection_service_builder.build()?); // Multiplex both grpc and http based on content-type - let service = MultiplexService::new(router, server_builder.into_service()); + let service = TowerToHyperService::new( + MultiplexService::new(router, server_builder.into_service()) + .map_request(|req: Request| req.map(boxed)), + ); - run_hyper_server( - &options.bind_address, - service, - cancellation_watcher(), - "node-grpc", - ) - .await?; + run_hyper_server(&options.bind_address, service, "node-grpc").await?; Ok(()) } } // handle 404 -async fn handler_404() -> (axum_0_6::http::StatusCode, &'static str) { +async fn handler_404() -> (axum::http::StatusCode, &'static str) { ( - axum_0_6::http::StatusCode::NOT_FOUND, + axum::http::StatusCode::NOT_FOUND, "Are you lost? Maybe visit https://restate.dev instead!", ) } diff --git a/crates/node/src/roles/admin.rs b/crates/node/src/roles/admin.rs index d1b7a44d1..f600a822d 100644 --- a/crates/node/src/roles/admin.rs +++ b/crates/node/src/roles/admin.rs @@ -13,7 +13,7 @@ use std::time::Duration; use anyhow::Context; use codederror::CodedError; use tokio::sync::oneshot; -use tonic_0_10::transport::Channel; +use tonic::transport::Channel; use restate_admin::cluster_controller::ClusterControllerHandle; use restate_admin::service::AdminService; diff --git a/crates/node/src/roles/worker.rs b/crates/node/src/roles/worker.rs index cb4f402a9..b6cf4a1c7 100644 --- a/crates/node/src/roles/worker.rs +++ b/crates/node/src/roles/worker.rs @@ -43,7 +43,7 @@ pub enum WorkerRoleError { pub enum SchemaError { #[error("failed to fetch schema updates: {0}")] #[code(unknown)] - Fetch(#[from] tonic_0_10::Status), + Fetch(#[from] tonic::Status), #[error("failed updating subscriptions: {0}")] #[code(unknown)] Subscription(#[from] restate_worker::WorkerHandleError), diff --git a/crates/partition-store/Cargo.toml b/crates/partition-store/Cargo.toml index 4729db8f8..e4a946fc0 100644 --- a/crates/partition-store/Cargo.toml +++ b/crates/partition-store/Cargo.toml @@ -29,7 +29,7 @@ futures = { workspace = true } futures-util = { workspace = true } once_cell = { workspace = true } paste = { workspace = true } -prost-0-12 = { workspace = true } +prost = { workspace = true } rocksdb = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } diff --git a/crates/partition-store/src/keys.rs b/crates/partition-store/src/keys.rs index 90da48217..d7712346f 100644 --- a/crates/partition-store/src/keys.rs +++ b/crates/partition-store/src/keys.rs @@ -11,7 +11,7 @@ use anyhow::anyhow; use bytes::{Buf, BufMut, Bytes, BytesMut}; use bytestring::ByteString; -use prost_0_12::encoding::encoded_len_varint; +use prost::encoding::encoded_len_varint; use std::mem; use strum_macros::EnumIter; @@ -576,13 +576,13 @@ impl KeyCodec for TimerKeyKind { #[inline] fn write_delimited(source: impl AsRef<[u8]>, target: &mut B) { let source = source.as_ref(); - prost_0_12::encoding::encode_varint(source.len() as u64, target); + prost::encoding::encode_varint(source.len() as u64, target); target.put(source); } #[inline] fn read_delimited(source: &mut B) -> crate::Result { - let len = prost_0_12::encoding::decode_varint(source) + let len = prost::encoding::decode_varint(source) .map_err(|error| StorageError::Generic(error.into()))?; // note: this is a zero-copy when the source is bytes::Bytes. Ok(source.copy_to_bytes(len as usize)) diff --git a/crates/serde-util/Cargo.toml b/crates/serde-util/Cargo.toml index 819d12ee7..289e4e865 100644 --- a/crates/serde-util/Cargo.toml +++ b/crates/serde-util/Cargo.toml @@ -10,7 +10,7 @@ publish = false [features] default = [] schema = ["dep:schemars"] -proto = ["dep:prost-0-12", "dep:bytes"] +proto = ["dep:prost", "dep:bytes"] [dependencies] bytes = { workspace = true, optional = true } @@ -19,7 +19,7 @@ http = { workspace = true } http-serde = { workspace = true } humantime = { workspace = true } iso8601 = "0.6.1" -prost-0-12 = { workspace = true, optional = true } +prost = { workspace = true, optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true } serde_with = { workspace = true } diff --git a/crates/serde-util/src/proto.rs b/crates/serde-util/src/proto.rs index 58f81cd5e..7c867bffc 100644 --- a/crates/serde-util/src/proto.rs +++ b/crates/serde-util/src/proto.rs @@ -19,7 +19,7 @@ pub struct ProtobufEncoded; impl SerializeAs for ProtobufEncoded where - T: prost_0_12::Message, + T: prost::Message, { fn serialize_as(source: &T, serializer: S) -> Result where @@ -31,7 +31,7 @@ where impl<'de, T> DeserializeAs<'de, T> for ProtobufEncoded where - T: prost_0_12::Message + Default, + T: prost::Message + Default, { fn deserialize_as(deserializer: D) -> Result where diff --git a/crates/service-protocol/Cargo.toml b/crates/service-protocol/Cargo.toml index 9a9bc44af..e98f6b053 100644 --- a/crates/service-protocol/Cargo.toml +++ b/crates/service-protocol/Cargo.toml @@ -31,7 +31,7 @@ http-body-util = { workspace = true, optional = true } itertools = { workspace = true } once_cell = { workspace = true } paste = { workspace = true, optional = true } -prost-0-12 = { workspace = true } +prost = { workspace = true } regress = { workspace = true, optional = true } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } diff --git a/crates/service-protocol/src/codec.rs b/crates/service-protocol/src/codec.rs index 78c1825f6..1bcdc32ea 100644 --- a/crates/service-protocol/src/codec.rs +++ b/crates/service-protocol/src/codec.rs @@ -9,7 +9,7 @@ // by the Apache License, Version 2.0. use bytes::{Buf, BufMut, Bytes, BytesMut}; -use prost_0_12::Message; +use prost::Message; use restate_types::invocation::Header; use restate_types::journal::enriched::{EnrichedEntryHeader, EnrichedRawEntry}; use restate_types::journal::raw::*; @@ -35,7 +35,7 @@ macro_rules! match_decode { }; } -#[derive(Clone, PartialEq, ::prost_0_12::Message)] +#[derive(Clone, PartialEq, ::prost::Message)] struct NamedEntryTemplate { // By spec the field `name` is always tag 12 #[prost(string, optional, tag = "12")] diff --git a/crates/service-protocol/src/lib.rs b/crates/service-protocol/src/lib.rs index 9df414302..63b8f7d9c 100644 --- a/crates/service-protocol/src/lib.rs +++ b/crates/service-protocol/src/lib.rs @@ -10,8 +10,6 @@ //! This crate contains the code-generated structs of [service-protocol](https://github.com/restatedev/service-protocol) and the codec to use them. -extern crate prost_0_12 as prost; - pub const RESTATE_SERVICE_PROTOCOL_VERSION: u16 = 2; #[cfg(feature = "codec")] diff --git a/crates/service-protocol/src/message/encoding.rs b/crates/service-protocol/src/message/encoding.rs index 68b1df436..53f48cc90 100644 --- a/crates/service-protocol/src/message/encoding.rs +++ b/crates/service-protocol/src/message/encoding.rs @@ -24,7 +24,7 @@ use tracing::warn; #[code(restate_errors::RT0012)] pub enum EncodingError { #[error("cannot decode message type {0:?}. This looks like a bug of the SDK. Reason: {1:?}")] - DecodeMessage(MessageType, #[source] prost_0_12::DecodeError), + DecodeMessage(MessageType, #[source] prost::DecodeError), #[error(transparent)] UnknownMessageType(#[from] UnknownMessageType), #[error("hit message size limit: {0} >= {1}")] @@ -66,7 +66,7 @@ impl Encoder { &self, mut buf: impl BufMut, msg: ProtocolMessage, - ) -> Result<(), prost_0_12::EncodeError> { + ) -> Result<(), prost::EncodeError> { let header = generate_header(&msg); buf.put_u64(header.into()); @@ -101,7 +101,7 @@ fn generate_header(msg: &ProtocolMessage) -> MessageHeader { } } -fn encode_msg(msg: &ProtocolMessage, buf: &mut impl BufMut) -> Result<(), prost_0_12::EncodeError> { +fn encode_msg(msg: &ProtocolMessage, buf: &mut impl BufMut) -> Result<(), prost::EncodeError> { match msg { ProtocolMessage::Start(m) => m.encode(buf), ProtocolMessage::Completion(m) => m.encode(buf), @@ -239,7 +239,7 @@ impl DecoderState { fn decode_protocol_message( header: &MessageHeader, mut buf: impl Buf, -) -> Result { +) -> Result { Ok(match header.message_type() { MessageType::Start => ProtocolMessage::Start(service_protocol::StartMessage::decode(buf)?), MessageType::Completion => { diff --git a/crates/service-protocol/src/message/mod.rs b/crates/service-protocol/src/message/mod.rs index 990e9bf56..9c6aa76a4 100644 --- a/crates/service-protocol/src/message/mod.rs +++ b/crates/service-protocol/src/message/mod.rs @@ -12,7 +12,7 @@ //! including encoding and decoding of headers and message payloads. use bytes::Bytes; -use prost_0_12::Message; +use prost::Message; use restate_types::journal::raw::PlainRawEntry; use restate_types::journal::CompletionResult; use restate_types::journal::{Completion, EntryIndex}; diff --git a/crates/storage-api/Cargo.toml b/crates/storage-api/Cargo.toml index 7b17f7803..20ac83b78 100644 --- a/crates/storage-api/Cargo.toml +++ b/crates/storage-api/Cargo.toml @@ -20,12 +20,12 @@ bytestring = { workspace = true } derive_more = { workspace = true } futures-util = { workspace = true } opentelemetry = { workspace = true } -prost-0-12 = { workspace = true } -prost-types-0-12 = { workspace = true } +prost = { workspace = true } +prost-types = { workspace = true } serde = { workspace = true, optional = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } [build-dependencies] -prost-build-0-12 = { workspace = true } \ No newline at end of file +prost-build = { workspace = true } \ No newline at end of file diff --git a/crates/storage-api/build.rs b/crates/storage-api/build.rs index fa4d901bb..2defa008a 100644 --- a/crates/storage-api/build.rs +++ b/crates/storage-api/build.rs @@ -9,7 +9,7 @@ // by the Apache License, Version 2.0. fn main() -> std::io::Result<()> { - prost_build_0_12::Config::new() + prost_build::Config::new() .bytes(["."]) // allow older protobuf compiler to be used .protoc_arg("--experimental_allow_proto3_optional") diff --git a/crates/storage-api/src/lib.rs b/crates/storage-api/src/lib.rs index c2b762eb7..daf109fd5 100644 --- a/crates/storage-api/src/lib.rs +++ b/crates/storage-api/src/lib.rs @@ -8,9 +8,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -extern crate prost_0_12 as prost; -extern crate prost_types_0_12 as prost_types; - use std::future::Future; /// Storage error diff --git a/crates/storage-api/src/storage.rs b/crates/storage-api/src/storage.rs index 5561f4071..259b56eb7 100644 --- a/crates/storage-api/src/storage.rs +++ b/crates/storage-api/src/storage.rs @@ -77,7 +77,7 @@ pub mod v1 { use bytes::{Buf, BufMut, Bytes}; use bytestring::ByteString; use opentelemetry::trace::TraceState; - use prost_0_12::Message; + use prost::Message; use restate_types::deployment::PinnedDeployment; use restate_types::errors::{IdDecodeError, InvocationError}; diff --git a/crates/storage-query-datafusion/Cargo.toml b/crates/storage-query-datafusion/Cargo.toml index 16738ac92..bc904ce48 100644 --- a/crates/storage-query-datafusion/Cargo.toml +++ b/crates/storage-query-datafusion/Cargo.toml @@ -30,7 +30,7 @@ datafusion = { workspace = true } derive_builder = { workspace = true } futures = { workspace = true } paste = { workspace = true } -prost-0-12 = { workspace = true } +prost = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/storage-query-datafusion/src/journal/tests.rs b/crates/storage-query-datafusion/src/journal/tests.rs index 77b63c89e..fe8735899 100644 --- a/crates/storage-query-datafusion/src/journal/tests.rs +++ b/crates/storage-query-datafusion/src/journal/tests.rs @@ -16,7 +16,7 @@ use datafusion::arrow::record_batch::RecordBatch; use futures::StreamExt; use googletest::all; use googletest::prelude::{assert_that, eq}; -use prost_0_12::Message; +use prost::Message; use restate_core::TaskCenterBuilder; use restate_service_protocol::codec::ProtobufRawEntryCodec; use restate_storage_api::journal_table::{JournalEntry, JournalTable}; diff --git a/crates/storage-query-postgres/Cargo.toml b/crates/storage-query-postgres/Cargo.toml index ed5f62e14..c97b6b88e 100644 --- a/crates/storage-query-postgres/Cargo.toml +++ b/crates/storage-query-postgres/Cargo.toml @@ -31,7 +31,7 @@ derive_builder = { workspace = true } futures = { workspace = true } paste = { workspace = true} pgwire = {version = "0.23", default-features = false, features = ["server-api-ring"]} -prost-0-12 = {workspace = true} +prost = {workspace = true} schemars = { workspace = true, optional = true } serde = { workspace = true } thiserror = { workspace = true } diff --git a/crates/test-util/Cargo.toml b/crates/test-util/Cargo.toml index 1925b7a19..565f4b986 100644 --- a/crates/test-util/Cargo.toml +++ b/crates/test-util/Cargo.toml @@ -8,13 +8,13 @@ license.workspace = true publish = false [features] -prost = ["dep:prost-0-12"] +prost = ["dep:prost"] [dependencies] assert2 = { workspace = true } googletest = { workspace = true } pretty_assertions = "1.3" -prost-0-12 = { workspace = true, optional = true } +prost = { workspace = true, optional = true } [dev-dependencies] -prost-types-0-12 = { workspace = true } +prost-types = { workspace = true } diff --git a/crates/test-util/src/matchers.rs b/crates/test-util/src/matchers.rs index 314c4f985..0bae9e5ac 100644 --- a/crates/test-util/src/matchers.rs +++ b/crates/test-util/src/matchers.rs @@ -17,14 +17,14 @@ pub use prost::protobuf_decoded; #[cfg(feature = "prost")] mod prost { use googletest::matcher::{Matcher, MatcherResult}; - use prost_0_12::bytes; + use prost::bytes; use std::fmt::Debug; use std::marker::PhantomData; struct ProtobufDecodeMatcher(InnerMatcher, PhantomData); impl< - T: prost_0_12::Message + Default, + T: prost::Message + Default, B: bytes::Buf + Clone + Debug, InnerMatcher: Matcher, > Matcher for ProtobufDecodeMatcher @@ -54,7 +54,7 @@ mod prost { } // Decode Bytes as protobuf - pub fn protobuf_decoded( + pub fn protobuf_decoded( inner: impl Matcher, ) -> impl Matcher { ProtobufDecodeMatcher(inner, Default::default()) @@ -65,8 +65,8 @@ mod prost { use super::*; use googletest::{assert_that, matchers::eq}; - use prost_0_12::Message; - use prost_types_0_12::Timestamp; + use prost::Message; + use prost_types::Timestamp; #[test] fn timestamp() { @@ -74,7 +74,7 @@ mod prost { assert_that!( bytes::Bytes::from(expected.encode_to_vec()), - protobuf_decoded(eq(expected.clone())) + protobuf_decoded(eq(expected)) ); assert_that!( expected.encode_to_vec().as_slice(), diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index ade948101..5ab5bea18 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -39,9 +39,9 @@ itertools = { workspace = true } num-traits = { version = "0.2.17" } once_cell = { workspace = true } opentelemetry = { workspace = true } -prost-0-12 = { workspace = true } +prost = { workspace = true } prost-dto = { workspace = true } -prost-types-0-12 = { workspace = true } +prost-types = { workspace = true } rand = { workspace = true } regress = { workspace = true } schemars = { workspace = true, optional = true } @@ -72,7 +72,7 @@ test-log = { workspace = true } tokio = { workspace = true, features = ["test-util"] } [build-dependencies] -prost-build-0-12 = { workspace = true } +prost-build = { workspace = true } prettyplease = "0.2" schemars = { workspace = true } serde_json = { workspace = true } diff --git a/crates/types/build.rs b/crates/types/build.rs index 09b5c998b..3a282c9d4 100644 --- a/crates/types/build.rs +++ b/crates/types/build.rs @@ -17,7 +17,7 @@ use typify::{TypeSpace, TypeSpaceSettings}; fn main() -> std::io::Result<()> { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - prost_build_0_12::Config::new() + prost_build::Config::new() .bytes(["."]) .protoc_arg("--experimental_allow_proto3_optional") .enum_attribute( @@ -84,7 +84,7 @@ fn main() -> std::io::Result<()> { } fn build_restate_proto(out_dir: &Path) -> std::io::Result<()> { - prost_build_0_12::Config::new() + prost_build::Config::new() .bytes(["."]) .enum_attribute( "TargetName", diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index a2cacad89..36fd28d6c 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -10,9 +10,6 @@ //! This crate contains the core types used by various Restate components. -extern crate prost_0_12 as prost; -extern crate prost_types_0_12 as prost_types; - mod base62_util; mod id_util; mod macros; diff --git a/crates/worker/Cargo.toml b/crates/worker/Cargo.toml index 0b2a10d16..92cbe4862 100644 --- a/crates/worker/Cargo.toml +++ b/crates/worker/Cargo.toml @@ -78,7 +78,7 @@ restate-service-protocol = { workspace = true, features = ["test-util"] } restate-storage-api = { workspace = true, features = ["test-util"] } restate-test-util = { workspace = true, features = ["prost"] } restate-types = { workspace = true, features = ["test-util"] } -prost-0-12 = { workspace = true } +prost = { workspace = true } googletest = { workspace = true } tempfile = { workspace = true } diff --git a/crates/worker/src/partition/state_machine/command_interpreter/tests.rs b/crates/worker/src/partition/state_machine/command_interpreter/tests.rs index d34c66137..e7c3755fb 100644 --- a/crates/worker/src/partition/state_machine/command_interpreter/tests.rs +++ b/crates/worker/src/partition/state_machine/command_interpreter/tests.rs @@ -14,7 +14,7 @@ use bytestring::ByteString; use futures::stream; use googletest::matcher::Matcher; use googletest::{all, any, assert_that, pat, unordered_elements_are}; -use prost_0_12::Message; +use prost::Message; use restate_invoker_api::EffectKind; use restate_service_protocol::awakeable_id::AwakeableIdentifier; use restate_service_protocol::codec::ProtobufRawEntryCodec; diff --git a/tools/mock-service-endpoint/Cargo.toml b/tools/mock-service-endpoint/Cargo.toml index 8dd55ccca..b4bfd1cda 100644 --- a/tools/mock-service-endpoint/Cargo.toml +++ b/tools/mock-service-endpoint/Cargo.toml @@ -18,7 +18,7 @@ hyper = { workspace = true, features = ["server"] } hyper-util = { workspace = true, features = ["full"] } restate-service-protocol = { workspace = true, features = ["message", "codec"] } restate-types = { workspace = true } -prost-0-12 = { workspace = true } +prost = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } diff --git a/tools/mock-service-endpoint/src/main.rs b/tools/mock-service-endpoint/src/main.rs index 942667d16..eacf74257 100644 --- a/tools/mock-service-endpoint/src/main.rs +++ b/tools/mock-service-endpoint/src/main.rs @@ -13,7 +13,7 @@ use hyper::server::conn::http2; use hyper::service::service_fn; use hyper::{Request, Response}; use hyper_util::rt::{TokioExecutor, TokioIo, TokioTimer}; -use prost_0_12::Message; +use prost::Message; use tokio::net::TcpListener; use tracing::{debug, error, info}; use tracing_subscriber::filter::LevelFilter; diff --git a/tools/restatectl/Cargo.toml b/tools/restatectl/Cargo.toml index c81279a06..b675465cb 100644 --- a/tools/restatectl/Cargo.toml +++ b/tools/restatectl/Cargo.toml @@ -19,11 +19,12 @@ clap-verbosity-flag = { version = "2.0.1" } cling = { version = "0.1.0", default-features = false, features = ["derive"] } crossterm = { version = "0.27.0" } ctrlc = { version = "3.4" } -prost-types-0-12 = { workspace = true } +hyper-util = { workspace = true } +prost-types = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } tokio-stream = { workspace = true } -tonic-0-10 = { workspace = true, features = ["transport", "prost"] } +tonic = { workspace = true, features = ["transport", "prost"] } tower = { workspace = true } tracing = { workspace = true } tracing-log = { version = "0.2" } diff --git a/tools/restatectl/src/commands/dump/cluster_state.rs b/tools/restatectl/src/commands/dump/cluster_state.rs index 04c6ab565..391bff989 100644 --- a/tools/restatectl/src/commands/dump/cluster_state.rs +++ b/tools/restatectl/src/commands/dump/cluster_state.rs @@ -26,7 +26,7 @@ use restate_types::protobuf::cluster::{ node_state, DeadNode, PartitionProcessorStatus, ReplayStatus, RunMode, }; use restate_types::{GenerationalNodeId, PlainNodeId}; -use tonic_0_10::codec::CompressionEncoding; +use tonic::codec::CompressionEncoding; use crate::app::ConnectionInfo; use crate::util::grpc_connect; @@ -185,7 +185,7 @@ fn render_replay_status(status: ReplayStatus, target_lsn: Option) -> Cell { } } -fn render_as_duration(ts: Option, tense: Tense) -> Cell { +fn render_as_duration(ts: Option, tense: Tense) -> Cell { let ts: Option = ts .map(TryInto::try_into) .transpose() diff --git a/tools/restatectl/src/util.rs b/tools/restatectl/src/util.rs index 7c5fd35d8..ef3453ba4 100644 --- a/tools/restatectl/src/util.rs +++ b/tools/restatectl/src/util.rs @@ -8,15 +8,15 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +use hyper_util::rt::TokioIo; use restate_cli_util::CliContext; use restate_types::net::AdvertisedAddress; +use tokio::io; use tokio::net::UnixStream; -use tonic_0_10::transport::{Channel, Endpoint, Uri}; +use tonic::transport::{Channel, Endpoint, Uri}; use tower::service_fn; -pub async fn grpc_connect( - address: AdvertisedAddress, -) -> Result { +pub async fn grpc_connect(address: AdvertisedAddress) -> Result { let ctx = CliContext::get(); match address { AdvertisedAddress::Uds(uds_path) => { @@ -24,9 +24,11 @@ pub async fn grpc_connect( Endpoint::try_from("http://127.0.0.1") .expect("/ should be a valid Uri") .connect_with_connector(service_fn(move |_: Uri| { - UnixStream::connect(uds_path.clone()) - })) - .await + let uds_path = uds_path.clone(); + async move { + Ok::<_, io::Error>(TokioIo::new(UnixStream::connect(uds_path).await?)) + } + })).await } AdvertisedAddress::Http(uri) => { Channel::builder( diff --git a/tools/xtask/Cargo.toml b/tools/xtask/Cargo.toml index bdeefde56..0c1775e0e 100644 --- a/tools/xtask/Cargo.toml +++ b/tools/xtask/Cargo.toml @@ -23,4 +23,4 @@ reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tl schemars = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } -tonic-0-10 = { workspace = true } +tonic = { workspace = true } diff --git a/tools/xtask/src/main.rs b/tools/xtask/src/main.rs index efb8b59d6..e3cf390d3 100644 --- a/tools/xtask/src/main.rs +++ b/tools/xtask/src/main.rs @@ -15,7 +15,7 @@ use std::{env, io}; use anyhow::bail; use reqwest::header::ACCEPT; use schemars::gen::SchemaSettings; -use tonic_0_10::transport::{Channel, Uri}; +use tonic::transport::{Channel, Uri}; use restate_admin::service::AdminService; use restate_bifrost::Bifrost; From b7b1c246a7794b676aa412d1a073496599232db9 Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Wed, 24 Jul 2024 15:51:33 +0200 Subject: [PATCH 5/5] Remove unnecessary Uri -> String -> Uri parse loops Since all components are now using http 1.0 we can directly pass on the respective types. --- crates/admin-rest-model/src/deployments.rs | 2 +- crates/admin/src/rest_api/deployments.rs | 2 +- tools/restatectl/src/util.rs | 15 ++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/crates/admin-rest-model/src/deployments.rs b/crates/admin-rest-model/src/deployments.rs index e6410b8cd..db7dcda4d 100644 --- a/crates/admin-rest-model/src/deployments.rs +++ b/crates/admin-rest-model/src/deployments.rs @@ -166,7 +166,7 @@ impl From for Deployment { protocol_type, http_version, } => Self::Http { - uri: address.to_string().parse().unwrap(), + uri: address, protocol_type, http_version, additional_headers: value.delivery_options.additional_headers.into(), diff --git a/crates/admin/src/rest_api/deployments.rs b/crates/admin/src/rest_api/deployments.rs index 20cfa171a..c18384056 100644 --- a/crates/admin/src/rest_api/deployments.rs +++ b/crates/admin/src/rest_api/deployments.rs @@ -54,7 +54,7 @@ pub async fn create_deployment( } => ( DiscoverEndpoint::new( Endpoint::Http( - uri.to_string().parse().unwrap(), + uri, if use_http_11 { http::Version::HTTP_11 } else { diff --git a/tools/restatectl/src/util.rs b/tools/restatectl/src/util.rs index ef3453ba4..9f79a42dc 100644 --- a/tools/restatectl/src/util.rs +++ b/tools/restatectl/src/util.rs @@ -31,15 +31,12 @@ pub async fn grpc_connect(address: AdvertisedAddress) -> Result { - Channel::builder( - // TODO we need this conversion because tonic still relies on http 0.1 - uri.to_string().parse().unwrap(), - ) - .connect_timeout(ctx.connect_timeout()) - .timeout(ctx.request_timeout()) - .http2_adaptive_window(true) - .connect() - .await + Channel::builder(uri) + .connect_timeout(ctx.connect_timeout()) + .timeout(ctx.request_timeout()) + .http2_adaptive_window(true) + .connect() + .await } } }