Skip to content

Commit

Permalink
Rename DetectHttp to NewServeHttp (#760)
Browse files Browse the repository at this point in the history
In preparation for an upcoming change that decouples HTTP detection
logic from server initialization, this chagne renames `DetectHttp` to
`NewServeHttp` and `AcceptHttp` to `ServeHttp`.
  • Loading branch information
olix0r committed Dec 5, 2020
1 parent c657b3e commit f977b67
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion linkerd/app/inbound/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl Config {
.check_new_service::<(http::Version, TcpAccept), http::Request<_>>()
.into_inner();

svc::stack(http::DetectHttp::new(
svc::stack(http::NewServeHttp::new(
h2_settings,
http_server,
svc::stack(tcp_forward)
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/src/ingress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ where
))
.into_inner();

svc::stack(http::DetectHttp::new(h2_settings, http, tcp, drain))
svc::stack(http::NewServeHttp::new(h2_settings, http, tcp, drain))
.check_new_service::<tcp::Accept, io::PrefixedIo<transport::metrics::SensorIo<I>>>()
.push_on_response(svc::layers().push_spawn_buffer(buffer_capacity).push(
transport::Prefix::layer(
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ where
.check_new_service::<tcp::Logical, transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>()
.into_inner();

let http = svc::stack(http::DetectHttp::new(
let http = svc::stack(http::NewServeHttp::new(
h2_settings,
http_server,
tcp_balance,
Expand Down
4 changes: 2 additions & 2 deletions linkerd/proxy/http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod add_header;
pub mod balance;
pub mod client;
pub mod client_handle;
pub mod detect;
mod glue;
pub mod h1;
pub mod h2;
Expand All @@ -17,6 +16,7 @@ pub mod insert;
pub mod normalize_uri;
pub mod orig_proto;
pub mod override_authority;
mod server;
pub mod strip_header;
pub mod timeout;
pub mod trace;
Expand All @@ -25,9 +25,9 @@ mod version;

pub use self::{
client_handle::{ClientHandle, SetClientHandle},
detect::DetectHttp,
glue::{Body as Payload, HyperServerSvc},
override_authority::CanOverrideAuthority,
server::NewServeHttp,
timeout::MakeTimeoutLayer,
version::Version,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tracing::{debug, trace};
type Server = hyper::server::conn::Http<trace::Executor>;

#[derive(Clone, Debug)]
pub struct DetectHttp<F, H> {
pub struct NewServeHttp<F, H> {
tcp: F,
http: H,
server: Server,
Expand All @@ -37,7 +37,7 @@ pub struct DetectHttp<F, H> {
/// Otherwise, the `F` type forwarding service is used to handle the TCP
/// connection.
#[derive(Debug)]
pub struct AcceptHttp<T, F: NewService<T>, H: NewService<(HttpVersion, T)>> {
pub struct ServeHttp<T, F: NewService<T>, H: NewService<(HttpVersion, T)>> {
target: T,
new_tcp: F,
tcp: Option<F::Service>,
Expand All @@ -48,10 +48,10 @@ pub struct AcceptHttp<T, F: NewService<T>, H: NewService<(HttpVersion, T)>> {
drain: drain::Watch,
}

// === impl DetectHttp ===
// === impl NewServeHttp ===

impl<F, H> DetectHttp<F, H> {
/// Creates a new `AcceptHttp`.
impl<F, H> NewServeHttp<F, H> {
/// Creates a new `ServeHttp`.
pub fn new(h2: H2Settings, http: H, tcp: F, drain: drain::Watch) -> Self {
let mut server = hyper::server::conn::Http::new().with_executor(trace::Executor::new());
server
Expand All @@ -77,15 +77,15 @@ impl<F, H> DetectHttp<F, H> {
}
}

impl<T, F, H> NewService<T> for DetectHttp<F, H>
impl<T, F, H> NewService<T> for NewServeHttp<F, H>
where
F: NewService<T> + Clone,
H: NewService<(HttpVersion, T)> + Clone,
{
type Service = AcceptHttp<T, F, H>;
type Service = ServeHttp<T, F, H>;

fn new_service(&mut self, target: T) -> Self::Service {
AcceptHttp::new(
ServeHttp::new(
target,
self.server.clone(),
self.http.clone(),
Expand All @@ -95,9 +95,9 @@ where
}
}

// === impl AcceptHttp ===
// === impl ServeHttp ===

impl<T, F, H> AcceptHttp<T, F, H>
impl<T, F, H> ServeHttp<T, F, H>
where
F: NewService<T>,
H: NewService<(HttpVersion, T)>,
Expand All @@ -116,7 +116,7 @@ where
}
}

impl<T, I, F, FSvc, H, HSvc> Service<PrefixedIo<I>> for AcceptHttp<T, F, H>
impl<T, I, F, FSvc, H, HSvc> Service<PrefixedIo<I>> for ServeHttp<T, F, H>
where
T: Clone,
I: io::AsyncRead + io::AsyncWrite + PeerAddr + Send + Unpin + 'static,
Expand Down

0 comments on commit f977b67

Please sign in to comment.