Skip to content

Commit

Permalink
Move HTTP detection & server into linkerd2_proxy_http (#619)
Browse files Browse the repository at this point in the history
In preparation for upcoming simplifications, this moves the HTTP
detection/serving logic into the linkerd2_proxy_http crate.
  • Loading branch information
olix0r authored Aug 5, 2020
1 parent 67c7744 commit 4982937
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ dependencies = [
name = "linkerd2-proxy-http"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes 0.5.4",
"futures 0.3.5",
"h2 0.2.6",
Expand All @@ -1290,6 +1291,9 @@ dependencies = [
"linkerd2-error",
"linkerd2-http-box",
"linkerd2-identity",
"linkerd2-proxy-core",
"linkerd2-proxy-detect",
"linkerd2-proxy-transport",
"linkerd2-stack",
"linkerd2-timeout",
"pin-project",
Expand Down
10 changes: 1 addition & 9 deletions linkerd/app/core/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ pub use linkerd2_proxy_api_resolve as api_resolve;
pub use linkerd2_proxy_core as core;
pub use linkerd2_proxy_detect as detect;
pub use linkerd2_proxy_discover as discover;
pub use linkerd2_proxy_http::{
self as http,
// TODO(eliza): port
// grpc
};
pub use linkerd2_proxy_http as http;
pub use linkerd2_proxy_identity as identity;
pub use linkerd2_proxy_resolve as resolve;
pub use linkerd2_proxy_tap as tap;
pub use linkerd2_proxy_tcp as tcp;

pub mod server;

pub use self::server::ServeHttp;
8 changes: 3 additions & 5 deletions linkerd/app/inbound/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ use linkerd2_app_core::{
proxy::{
detect,
http::{self, normalize_uri, orig_proto, strip_header},
identity,
server::{DetectHttp, ServeHttp},
tap, tcp,
identity, tap, tcp,
},
reconnect, router, serve,
spans::SpanConverter,
Expand Down Expand Up @@ -404,15 +402,15 @@ impl Config {
)
});

let tcp_server = ServeHttp::new(
let tcp_server = http::ServeHttp::new(
http_server.into_inner(),
h2_settings,
tcp_forward.into_inner(),
drain.clone(),
);

let tcp_detect = svc::stack(tcp_server)
.push(detect::AcceptLayer::new(DetectHttp::new(
.push(detect::AcceptLayer::new(http::DetectHttp::new(
disable_protocol_detection_for_ports.clone(),
)))
.push(admit::AdmitLayer::new(require_identity_for_inbound_ports))
Expand Down
8 changes: 4 additions & 4 deletions linkerd/app/outbound/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use linkerd2_app_core::{
opencensus::proto::trace::v1 as oc,
profiles,
proxy::{
self, core::resolve::Resolve, detect, discover, http, identity, resolve::map_endpoint,
server::DetectHttp, tap, tcp, ServeHttp,
self, core::resolve::Resolve, detect, discover, http, identity, resolve::map_endpoint, tap,
tcp,
},
reconnect, retry, router, serve,
spans::SpanConverter,
Expand Down Expand Up @@ -531,7 +531,7 @@ impl Config {
)
.check_new_service::<tls::accept::Meta>();

let tcp_server = ServeHttp::new(
let tcp_server = http::ServeHttp::new(
http_server.into_inner(),
h2_settings,
tcp_forward.into_inner(),
Expand All @@ -542,7 +542,7 @@ impl Config {
Conditional::None(tls::ReasonForNoPeerName::Loopback);

let tcp_detect = svc::stack(tcp_server)
.push(detect::AcceptLayer::new(DetectHttp::new(
.push(detect::AcceptLayer::new(http::DetectHttp::new(
disable_protocol_detection_for_ports.clone(),
)))
.push(metrics.transport.layer_accept(TransportLabels))
Expand Down
4 changes: 4 additions & 0 deletions linkerd/proxy/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This should probably be decomposed into smaller, decoupled crates.
"""

[dependencies]
async-trait = "0.1"
bytes = "0.5"
futures = { package = "futures", version = "0.3" }
h2 = "0.2.6"
Expand All @@ -27,6 +28,9 @@ linkerd2-duplex = { path = "../../duplex" }
linkerd2-error = { path = "../../error" }
linkerd2-http-box = { path = "../../http-box" }
linkerd2-identity = { path = "../../identity" }
linkerd2-proxy-core = { path = "../core" }
linkerd2-proxy-detect = { path = "../detect" }
linkerd2-proxy-transport = { path = "../transport" }
linkerd2-stack = { path = "../../stack" }
linkerd2-timeout = { path = "../../timeout" }
rand = "0.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
use crate::proxy::http::{
self,
use crate::Error;
use crate::{
self as http,
glue::{Body, HyperServerSvc},
h2::Settings as H2Settings,
trace, upgrade, Version as HttpVersion,
};
use crate::transport::{
io::{self, BoxedIo, Peekable},
tls,
};
use crate::{
drain,
proxy::{core::Accept, detect},
svc::{NewService, Service, ServiceExt},
Error,
};
use async_trait::async_trait;
use futures::TryFutureExt;
use futures::prelude::*;
use hyper;
use indexmap::IndexSet;
use linkerd2_drain as drain;
use linkerd2_proxy_core::Accept;
use linkerd2_proxy_detect as detect;
use linkerd2_proxy_transport::{
io::{self, BoxedIo, Peekable},
tls,
};
use linkerd2_stack::NewService;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use tower::{util::ServiceExt, Service};
use tracing::{info_span, trace};
use tracing_futures::Instrument;

Expand Down
2 changes: 2 additions & 0 deletions linkerd/proxy/http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod add_header;
pub mod balance;
pub mod canonicalize;
pub mod client;
pub mod detect;
pub mod glue;
pub mod h1;
pub mod h2;
Expand All @@ -25,6 +26,7 @@ mod version;

pub use self::{
client::MakeClientLayer,
detect::{DetectHttp, ServeHttp},
glue::{Body, HyperServerSvc},
settings::Settings,
timeout::MakeTimeoutLayer,
Expand Down

0 comments on commit 4982937

Please sign in to comment.