refactor: Re-export crates used by the ioxd_common macros
This allows the consumers of the macros to avoid including the dependencies themselves, which they otherwise wouldn't need to.pull/24376/head
parent
1759443a13
commit
90502c844b
|
@ -2512,6 +2512,7 @@ dependencies = [
|
|||
"dml",
|
||||
"flate2",
|
||||
"futures",
|
||||
"generated_types",
|
||||
"hashbrown 0.12.0",
|
||||
"http",
|
||||
"hyper",
|
||||
|
@ -2528,12 +2529,14 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"service_grpc_testing",
|
||||
"snafu",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util 0.7.1",
|
||||
"tonic",
|
||||
"tonic-health",
|
||||
"tonic-reflection",
|
||||
"tower",
|
||||
"trace",
|
||||
"trace_exporters",
|
||||
|
|
|
@ -10,12 +10,14 @@ edition = "2021"
|
|||
clap_blocks = { path = "../clap_blocks" }
|
||||
data_types = { path = "../data_types" }
|
||||
dml = { path = "../dml" }
|
||||
generated_types = { path = "../generated_types" }
|
||||
metric = { path = "../metric" }
|
||||
observability_deps = { path = "../observability_deps" }
|
||||
predicate = { path = "../predicate" }
|
||||
pprof = { version = "0.8", default-features = false, features = ["flamegraph", "prost-codec"], optional = true }
|
||||
metric_exporters = { path = "../metric_exporters" }
|
||||
mutable_batch_lp = { path = "../mutable_batch_lp" }
|
||||
observability_deps = { path = "../observability_deps" }
|
||||
pprof = { version = "0.8", default-features = false, features = ["flamegraph", "prost-codec"], optional = true }
|
||||
predicate = { path = "../predicate" }
|
||||
service_grpc_testing = { path = "../service_grpc_testing" }
|
||||
trace = { path = "../trace" }
|
||||
trace_exporters = { path = "../trace_exporters" }
|
||||
trace_http = { path = "../trace_http" }
|
||||
|
@ -39,10 +41,11 @@ serde_json = "1.0.81"
|
|||
serde_urlencoded = "0.7.0"
|
||||
snafu = "0.7"
|
||||
tokio = { version = "1.18", features = ["macros", "net", "parking_lot", "rt-multi-thread", "signal", "sync", "time"] }
|
||||
tokio-util = { version = "0.7.0" }
|
||||
tokio-stream = { version = "0.1", features = ["net"] }
|
||||
tokio-util = { version = "0.7.0" }
|
||||
tonic = "0.7"
|
||||
tonic-health = "0.6.0"
|
||||
tonic-reflection = "0.4.0"
|
||||
tower = "0.4"
|
||||
workspace-hack = { path = "../workspace-hack"}
|
||||
|
||||
|
|
|
@ -3,6 +3,18 @@ pub mod rpc;
|
|||
pub mod server_type;
|
||||
mod service;
|
||||
|
||||
// These crates are used by the macros we export; provide a stable
|
||||
// path to use them from in downstream crates.
|
||||
pub mod reexport {
|
||||
pub use generated_types;
|
||||
pub use service_grpc_testing;
|
||||
pub use tokio_stream;
|
||||
pub use tonic;
|
||||
pub use tonic_health;
|
||||
pub use tonic_reflection;
|
||||
pub use trace_http;
|
||||
}
|
||||
|
||||
pub use service::Service;
|
||||
|
||||
use crate::server_type::{CommonServerState, ServerType};
|
||||
|
|
|
@ -49,7 +49,7 @@ macro_rules! add_service {
|
|||
} = $builder;
|
||||
let service = $svc;
|
||||
|
||||
let status = tonic_health::ServingStatus::Serving;
|
||||
let status = $crate::reexport::tonic_health::ServingStatus::Serving;
|
||||
health_reporter
|
||||
.set_service_status(service_name(&service), status)
|
||||
.await;
|
||||
|
@ -75,7 +75,7 @@ macro_rules! add_service {
|
|||
macro_rules! setup_builder {
|
||||
($input:ident, $server_type:ident) => {{
|
||||
#[allow(unused_imports)]
|
||||
use ioxd_common::{add_service, rpc::RpcBuilder, server_type::ServerType};
|
||||
use $crate::{add_service, rpc::RpcBuilder, server_type::ServerType};
|
||||
|
||||
let RpcBuilderInput {
|
||||
socket,
|
||||
|
@ -83,14 +83,17 @@ macro_rules! setup_builder {
|
|||
shutdown,
|
||||
} = $input;
|
||||
|
||||
let (health_reporter, health_service) = tonic_health::server::health_reporter();
|
||||
let reflection_service = tonic_reflection::server::Builder::configure()
|
||||
.register_encoded_file_descriptor_set(generated_types::FILE_DESCRIPTOR_SET)
|
||||
let (health_reporter, health_service) =
|
||||
$crate::reexport::tonic_health::server::health_reporter();
|
||||
let reflection_service = $crate::reexport::tonic_reflection::server::Builder::configure()
|
||||
.register_encoded_file_descriptor_set(
|
||||
$crate::reexport::generated_types::FILE_DESCRIPTOR_SET,
|
||||
)
|
||||
.build()
|
||||
.expect("gRPC reflection data broken");
|
||||
|
||||
let builder = tonic::transport::Server::builder();
|
||||
let builder = builder.layer(trace_http::tower::TraceLayer::new(
|
||||
let builder = $crate::reexport::tonic::transport::Server::builder();
|
||||
let builder = builder.layer($crate::reexport::trace_http::tower::TraceLayer::new(
|
||||
trace_header_parser,
|
||||
$server_type.metric_registry(),
|
||||
$server_type.trace_collector(),
|
||||
|
@ -106,7 +109,10 @@ macro_rules! setup_builder {
|
|||
|
||||
add_service!(builder, health_service);
|
||||
add_service!(builder, reflection_service);
|
||||
add_service!(builder, service_grpc_testing::make_server());
|
||||
add_service!(
|
||||
builder,
|
||||
$crate::reexport::service_grpc_testing::make_server()
|
||||
);
|
||||
|
||||
builder
|
||||
}};
|
||||
|
@ -116,7 +122,7 @@ macro_rules! setup_builder {
|
|||
#[macro_export]
|
||||
macro_rules! serve_builder {
|
||||
($builder:ident) => {{
|
||||
use tokio_stream::wrappers::TcpListenerStream;
|
||||
use $crate::reexport::tokio_stream::wrappers::TcpListenerStream;
|
||||
use $crate::rpc::RpcBuilder;
|
||||
|
||||
let RpcBuilder {
|
||||
|
|
Loading…
Reference in New Issue