Skip to content

Commit

Permalink
bump service to stable v2
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Apr 16, 2021
1 parent 8d88a0a commit d8f56ee
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 174 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ actix-macros = "0.2.0"
actix-router = "0.2.7"
actix-rt = "2.2"
actix-server = "2.0.0-beta.3"
actix-service = "2.0.0-beta.4"
actix-service = "2.0.0"
actix-utils = "3.0.0-beta.4"
actix-tls = { version = "3.0.0-beta.5", default-features = false, optional = true }

Expand Down
2 changes: 1 addition & 1 deletion actix-files/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ path = "src/lib.rs"

[dependencies]
actix-web = { version = "4.0.0-beta.5", default-features = false }
actix-service = "2.0.0-beta.4"
actix-service = "2.0.0"
actix-utils = "3.0.0-beta.4"

askama_escape = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion actix-http-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ default = []
openssl = ["tls-openssl", "awc/openssl"]

[dependencies]
actix-service = "2.0.0-beta.4"
actix-service = "2.0.0"
actix-codec = "0.4.0-beta.1"
actix-tls = "3.0.0-beta.5"
actix-utils = "3.0.0-beta.4"
Expand Down
2 changes: 1 addition & 1 deletion actix-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ compress = ["flate2", "brotli2"]
trust-dns = ["trust-dns-resolver"]

[dependencies]
actix-service = "2.0.0-beta.4"
actix-service = "2.0.0"
actix-codec = "0.4.0-beta.1"
actix-utils = "3.0.0-beta.4"
actix-rt = "2.2"
Expand Down
42 changes: 20 additions & 22 deletions actix-http/src/h1/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use std::{fmt, net};

use actix_codec::{AsyncRead, AsyncWrite, Framed};
use actix_rt::net::TcpStream;
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
use actix_service::{
fn_service, IntoServiceFactory, Service, ServiceFactory, ServiceFactoryExt as _,
};
use actix_utils::future::ready;
use futures_core::future::LocalBoxFuture;

Expand Down Expand Up @@ -82,7 +84,7 @@ where
Error = DispatchError,
InitError = (),
> {
pipeline_factory(|io: TcpStream| {
fn_service(|io: TcpStream| {
let peer_addr = io.peer_addr().ok();
ready(Ok((io, peer_addr)))
})
Expand Down Expand Up @@ -132,16 +134,14 @@ mod openssl {
Error = TlsError<SslError, DispatchError>,
InitError = (),
> {
pipeline_factory(
Acceptor::new(acceptor)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!()),
)
.and_then(|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().peer_addr().ok();
ready(Ok((io, peer_addr)))
})
.and_then(self.map_err(TlsError::Service))
Acceptor::new(acceptor)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!())
.and_then(|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().peer_addr().ok();
ready(Ok((io, peer_addr)))
})
.and_then(self.map_err(TlsError::Service))
}
}
}
Expand Down Expand Up @@ -190,16 +190,14 @@ mod rustls {
Error = TlsError<io::Error, DispatchError>,
InitError = (),
> {
pipeline_factory(
Acceptor::new(config)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!()),
)
.and_then(|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().0.peer_addr().ok();
ready(Ok((io, peer_addr)))
})
.and_then(self.map_err(TlsError::Service))
Acceptor::new(config)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!())
.and_then(|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().0.peer_addr().ok();
ready(Ok((io, peer_addr)))
})
.and_then(self.map_err(TlsError::Service))
}
}
}
Expand Down
60 changes: 28 additions & 32 deletions actix-http/src/h2/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::{net, rc::Rc};
use actix_codec::{AsyncRead, AsyncWrite};
use actix_rt::net::TcpStream;
use actix_service::{
fn_factory, fn_service, pipeline_factory, IntoServiceFactory, Service,
ServiceFactory,
fn_factory, fn_service, IntoServiceFactory, Service, ServiceFactory,
ServiceFactoryExt as _,
};
use actix_utils::future::ready;
use bytes::Bytes;
Expand Down Expand Up @@ -81,12 +81,12 @@ where
Error = DispatchError,
InitError = S::InitError,
> {
pipeline_factory(fn_factory(|| {
fn_factory(|| {
ready(Ok::<_, S::InitError>(fn_service(|io: TcpStream| {
let peer_addr = io.peer_addr().ok();
ready(Ok::<_, DispatchError>((io, peer_addr)))
})))
}))
})
.and_then(self)
}
}
Expand Down Expand Up @@ -119,20 +119,18 @@ mod openssl {
Error = TlsError<SslError, DispatchError>,
InitError = S::InitError,
> {
pipeline_factory(
Acceptor::new(acceptor)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!()),
)
.and_then(fn_factory(|| {
ready(Ok::<_, S::InitError>(fn_service(
|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().peer_addr().ok();
ready(Ok((io, peer_addr)))
},
)))
}))
.and_then(self.map_err(TlsError::Service))
Acceptor::new(acceptor)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!())
.and_then(fn_factory(|| {
ready(Ok::<_, S::InitError>(fn_service(
|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().peer_addr().ok();
ready(Ok((io, peer_addr)))
},
)))
}))
.and_then(self.map_err(TlsError::Service))
}
}
}
Expand Down Expand Up @@ -168,20 +166,18 @@ mod rustls {
let protos = vec!["h2".to_string().into()];
config.set_protocols(&protos);

pipeline_factory(
Acceptor::new(config)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!()),
)
.and_then(fn_factory(|| {
ready(Ok::<_, S::InitError>(fn_service(
|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().0.peer_addr().ok();
ready(Ok((io, peer_addr)))
},
)))
}))
.and_then(self.map_err(TlsError::Service))
Acceptor::new(config)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!())
.and_then(fn_factory(|| {
ready(Ok::<_, S::InitError>(fn_service(
|io: TlsStream<TcpStream>| {
let peer_addr = io.get_ref().0.peer_addr().ok();
ready(Ok((io, peer_addr)))
},
)))
}))
.and_then(self.map_err(TlsError::Service))
}
}
}
Expand Down
71 changes: 35 additions & 36 deletions actix-http/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use std::{

use actix_codec::{AsyncRead, AsyncWrite, Framed};
use actix_rt::net::TcpStream;
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
use actix_service::{
fn_service, IntoServiceFactory, Service, ServiceFactory, ServiceFactoryExt as _,
};
use bytes::Bytes;
use futures_core::{future::LocalBoxFuture, ready};
use h2::server::{handshake, Handshake};
Expand Down Expand Up @@ -180,7 +182,7 @@ where
Error = DispatchError,
InitError = (),
> {
pipeline_factory(|io: TcpStream| async {
fn_service(|io: TcpStream| async {
let peer_addr = io.peer_addr().ok();
Ok((io, Protocol::Http1, peer_addr))
})
Expand Down Expand Up @@ -232,25 +234,23 @@ mod openssl {
Error = TlsError<SslError, DispatchError>,
InitError = (),
> {
pipeline_factory(
Acceptor::new(acceptor)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!()),
)
.and_then(|io: TlsStream<TcpStream>| async {
let proto = if let Some(protos) = io.ssl().selected_alpn_protocol() {
if protos.windows(2).any(|window| window == b"h2") {
Protocol::Http2
Acceptor::new(acceptor)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!())
.and_then(|io: TlsStream<TcpStream>| async {
let proto = if let Some(protos) = io.ssl().selected_alpn_protocol() {
if protos.windows(2).any(|window| window == b"h2") {
Protocol::Http2
} else {
Protocol::Http1
}
} else {
Protocol::Http1
}
} else {
Protocol::Http1
};
let peer_addr = io.get_ref().peer_addr().ok();
Ok((io, proto, peer_addr))
})
.and_then(self.map_err(TlsError::Service))
};
let peer_addr = io.get_ref().peer_addr().ok();
Ok((io, proto, peer_addr))
})
.and_then(self.map_err(TlsError::Service))
}
}
}
Expand Down Expand Up @@ -304,25 +304,24 @@ mod rustls {
let protos = vec!["h2".to_string().into(), "http/1.1".to_string().into()];
config.set_protocols(&protos);

pipeline_factory(
Acceptor::new(config)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!()),
)
.and_then(|io: TlsStream<TcpStream>| async {
let proto = if let Some(protos) = io.get_ref().1.get_alpn_protocol() {
if protos.windows(2).any(|window| window == b"h2") {
Protocol::Http2
Acceptor::new(config)
.map_err(TlsError::Tls)
.map_init_err(|_| panic!())
.and_then(|io: TlsStream<TcpStream>| async {
let proto = if let Some(protos) = io.get_ref().1.get_alpn_protocol()
{
if protos.windows(2).any(|window| window == b"h2") {
Protocol::Http2
} else {
Protocol::Http1
}
} else {
Protocol::Http1
}
} else {
Protocol::Http1
};
let peer_addr = io.get_ref().0.peer_addr().ok();
Ok((io, proto, peer_addr))
})
.and_then(self.map_err(TlsError::Service))
};
let peer_addr = io.get_ref().0.peer_addr().ok();
Ok((io, proto, peer_addr))
})
.and_then(self.map_err(TlsError::Service))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion actix-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ openssl = ["tls-openssl", "actix-http/openssl"]
actix-codec = "0.4.0-beta.1"
actix-http = "3.0.0-beta.5"
actix-http-test = { version = "3.0.0-beta.4", features = [] }
actix-service = "2.0.0-beta.4"
actix-service = "2.0.0"
actix-utils = "3.0.0-beta.2"
actix-web = { version = "4.0.0-beta.5", default-features = false, features = ["cookies"] }
actix-rt = "2.1"
Expand Down
2 changes: 1 addition & 1 deletion awc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ trust-dns = ["actix-http/trust-dns"]

[dependencies]
actix-codec = "0.4.0-beta.1"
actix-service = "2.0.0-beta.4"
actix-service = "2.0.0"
actix-http = "3.0.0-beta.5"
actix-rt = { version = "2.1", default-features = false }

Expand Down
12 changes: 6 additions & 6 deletions awc/tests/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use actix_http::{
HttpService,
};
use actix_http_test::test_server;
use actix_service::{map_config, pipeline_factory};
use actix_service::{fn_service, map_config, ServiceFactoryExt as _};
use actix_web::{
dev::{AppConfig, BodyEncoding},
http::header,
Expand Down Expand Up @@ -239,7 +239,7 @@ async fn test_connection_reuse() {

let srv = test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
fn_service(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
Expand Down Expand Up @@ -276,7 +276,7 @@ async fn test_connection_force_close() {

let srv = test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
fn_service(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
Expand Down Expand Up @@ -313,7 +313,7 @@ async fn test_connection_server_close() {

let srv = test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
fn_service(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
Expand Down Expand Up @@ -353,7 +353,7 @@ async fn test_connection_wait_queue() {

let srv = test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
fn_service(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
Expand Down Expand Up @@ -401,7 +401,7 @@ async fn test_connection_wait_queue_force_close() {

let srv = test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
fn_service(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
Expand Down
4 changes: 2 additions & 2 deletions awc/tests/test_ssl_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::Arc;

use actix_http::HttpService;
use actix_http_test::test_server;
use actix_service::{map_config, pipeline_factory, ServiceFactoryExt};
use actix_service::{map_config, fn_service, ServiceFactoryExt};
use actix_utils::future::ok;
use actix_web::http::Version;
use actix_web::{dev::AppConfig, web, App, HttpResponse};
Expand Down Expand Up @@ -48,7 +48,7 @@ async fn test_connection_reuse_h2() {

let srv = test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
fn_service(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
Expand Down

0 comments on commit d8f56ee

Please sign in to comment.