Skip to content

Commit 0c23ef9

Browse files
author
Thea Heinen
committed
Re-export Hyper types used in public API
Foundations uses Hyper types in it's public API for `TelemetryServerRoute` which means any users will need to add an explicit dependency on the same version of hyper and ensure it stays matching. Re-exporting the types will allow users to explicitly use the same types as foundations is using.
1 parent f7e1f04 commit 0c23ef9

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

examples/http_server/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ use self::settings::{EndpointSettings, HttpServerSettings, ResponseSettings};
1515
use anyhow::anyhow;
1616
use foundations::cli::{Arg, ArgAction, Cli};
1717
use foundations::settings::collections::Map;
18-
use foundations::telemetry::{self, log, tracing, TelemetryConfig, TelemetryContext};
18+
use foundations::telemetry::{
19+
self,
20+
hyper::{Body, Request, Response},
21+
log, tracing, TelemetryConfig, TelemetryContext,
22+
};
1923
use foundations::BootstrapResult;
2024
use futures_util::stream::{FuturesUnordered, StreamExt};
2125
use hyper::server::conn::Http;
2226
use hyper::service::service_fn;
23-
use hyper::{Body, Request, Response};
2427
use std::convert::Infallible;
2528
use std::net::{SocketAddr, TcpListener as StdTcpListener};
2629
use std::sync::Arc;

foundations/src/telemetry/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ pub use self::memory_profiler::MemoryProfiler;
119119
#[cfg(feature = "telemetry-server")]
120120
pub use self::server::{TelemetryRouteHandler, TelemetryRouteHandlerFuture, TelemetryServerRoute};
121121

122+
#[cfg(feature = "telemetry-server")]
123+
/// Re-exported types from Hyper which are used in foundations public API
124+
pub mod hyper {
125+
pub use hyper::{Body, Method, Request, Response};
126+
}
127+
122128
pub use self::driver::TelemetryDriver;
123129
pub use self::telemetry_context::{
124130
TelemetryContext, WithTelemetryContext, WithTelemetryContextLocal,

foundations/src/telemetry/server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ use super::settings::TelemetrySettings;
44
#[cfg(feature = "tracing")]
55
use super::tracing;
66
use crate::BootstrapResult;
7+
use crate::telemetry::hyper::{Body, Method, Request, Response};
78
use anyhow::Context as _;
89
use futures_util::future::{BoxFuture, FutureExt};
910
use hyper::server::conn::{AddrIncoming, AddrStream};
1011
use hyper::service::Service;
11-
use hyper::{header, Body, Method, Request, Response, Server, StatusCode};
12+
use hyper::{header, Server, StatusCode};
1213
use percent_encoding::percent_decode_str;
1314
use socket2::{Domain, SockAddr, Socket, Type};
1415
use std::collections::HashMap;

foundations/tests/telemetry_server.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use foundations::telemetry::settings::{
22
LivenessTrackingSettings, TelemetryServerSettings, TelemetrySettings, TracingSettings,
33
};
4-
use foundations::telemetry::{TelemetryConfig, TelemetryContext, TelemetryServerRoute};
4+
use foundations::telemetry::{
5+
hyper::{Method, Response},
6+
TelemetryConfig, TelemetryContext, TelemetryServerRoute,
7+
};
58
use futures_util::FutureExt;
6-
use hyper::{Method, Response};
79
use std::net::{Ipv4Addr, SocketAddr};
810

911
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)