mirror of https://github.com/fafhrd91/actix-net
Merge branch 'master' into workers-0-defaults-to-num-cpus
This commit is contained in:
commit
6067ed454a
|
@ -13,7 +13,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
|
|
@ -14,7 +14,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
version:
|
version:
|
||||||
- 1.39.0
|
- 1.42.0
|
||||||
- stable
|
- stable
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install ${{ matrix.version }}
|
- name: Install ${{ matrix.version }}
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
@ -65,7 +65,7 @@ jobs:
|
||||||
- name: Generate coverage file
|
- name: Generate coverage file
|
||||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||||
run: |
|
run: |
|
||||||
which cargo-tarpaulin || cargo install cargo-tarpaulin
|
cargo install cargo-tarpaulin
|
||||||
cargo tarpaulin --out Xml --workspace --all-features
|
cargo tarpaulin --out Xml --workspace --all-features
|
||||||
|
|
||||||
- name: Upload to Codecov
|
- name: Upload to Codecov
|
||||||
|
@ -76,5 +76,7 @@ jobs:
|
||||||
|
|
||||||
- name: Clear the cargo caches
|
- name: Clear the cargo caches
|
||||||
run: |
|
run: |
|
||||||
which cargo-cache || cargo install cargo-cache --no-default-features --features ci-autoclean
|
rustup update stable
|
||||||
|
rustup override set stable
|
||||||
|
cargo install cargo-cache --no-default-features --features ci-autoclean
|
||||||
cargo-cache
|
cargo-cache
|
||||||
|
|
|
@ -21,7 +21,7 @@ jobs:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install ${{ matrix.version }}
|
- name: Install ${{ matrix.version }}
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
|
|
@ -21,7 +21,7 @@ jobs:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install ${{ matrix.version }}
|
- name: Install ${{ matrix.version }}
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
@ -31,12 +31,12 @@ jobs:
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
- name: Install MSYS2
|
- name: Install MSYS2
|
||||||
uses: numworks/setup-msys2@v1
|
uses: msys2/setup-msys2@v2
|
||||||
|
|
||||||
- name: Install packages
|
- name: Install packages
|
||||||
run: |
|
run: |
|
||||||
msys2do pacman -Sy --noconfirm pacman
|
msys2 -c 'pacman -Sy --noconfirm pacman'
|
||||||
msys2do pacman --noconfirm -S base-devel pkg-config
|
msys2 -c 'pacman --noconfirm -S base-devel pkg-config'
|
||||||
|
|
||||||
- name: check build
|
- name: check build
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
|
|
|
@ -27,7 +27,7 @@ jobs:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install ${{ matrix.version }}
|
- name: Install ${{ matrix.version }}
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
|
|
@ -13,8 +13,8 @@ Actix net - framework for composable network services
|
||||||
|
|
||||||
## Documentation & community resources
|
## Documentation & community resources
|
||||||
|
|
||||||
* [Chat on gitter](https://gitter.im/actix/actix)
|
* [Chat on Gitter](https://gitter.im/actix/actix)
|
||||||
* Minimum supported Rust version: 1.39 or later
|
* Minimum supported Rust version: 1.42 or later
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [unreleased]
|
## Unreleased
|
||||||
|
|
||||||
|
|
||||||
|
## 2.0.0-alpha.4 - 2020-08-17
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
* Update `rustls` dependency to 0.18
|
* Update `rustls` dependency to 0.18
|
||||||
* Update `tokio-rustls` dependency to 0.14
|
* Update `tokio-rustls` dependency to 0.14
|
||||||
|
|
||||||
|
|
||||||
## [2.0.0-alpha.3] - 2020-05-08
|
## [2.0.0-alpha.3] - 2020-05-08
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-connect"
|
name = "actix-connect"
|
||||||
version = "2.0.0-alpha.3"
|
version = "2.0.0-alpha.4"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix connect - tcp connector service"
|
description = "Actix connect - tcp connector service"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
|
|
@ -277,7 +277,7 @@ impl ServerBuilder {
|
||||||
info!("Starting \"{}\" service on {}", sock.1, sock.2);
|
info!("Starting \"{}\" service on {}", sock.1, sock.2);
|
||||||
}
|
}
|
||||||
self.accept.start(
|
self.accept.start(
|
||||||
mem::replace(&mut self.sockets, Vec::new())
|
mem::take(&mut self.sockets)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|t| (t.0, t.2))
|
.map(|t| (t.0, t.2))
|
||||||
.collect(),
|
.collect(),
|
||||||
|
@ -356,7 +356,7 @@ impl ServerBuilder {
|
||||||
|
|
||||||
// stop accept thread
|
// stop accept thread
|
||||||
self.accept.send(Command::Stop);
|
self.accept.send(Command::Stop);
|
||||||
let notify = std::mem::replace(&mut self.notify, Vec::new());
|
let notify = std::mem::take(&mut self.notify);
|
||||||
|
|
||||||
// stop workers
|
// stop workers
|
||||||
if !self.workers.is_empty() && graceful {
|
if !self.workers.is_empty() && graceful {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased - 2020-xx-xx
|
||||||
|
|
||||||
|
|
||||||
|
## 1.0.6 - 2020-08-09
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-service"
|
name = "actix-service"
|
||||||
version = "1.0.5"
|
version = "1.0.6"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix service"
|
description = "Service trait and combinators for representing asynchronous request/response operations."
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures", "service"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-net.git"
|
repository = "https://github.com/actix/actix-net.git"
|
||||||
documentation = "https://docs.rs/actix-service/"
|
documentation = "https://docs.rs/actix-service"
|
||||||
|
readme = "README.md"
|
||||||
categories = ["network-programming", "asynchronous"]
|
categories = ["network-programming", "asynchronous"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# actix-service
|
||||||
|
|
||||||
|
> Service trait and combinators for representing asynchronous request/response operations.
|
||||||
|
|
||||||
|
See documentation for detailed explanations these components: [https://docs.rs/actix-service](docs).
|
||||||
|
|
||||||
|
[docs]: https://docs.rs/actix-service
|
|
@ -293,9 +293,8 @@ where
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
// benchmark body
|
// benchmark body
|
||||||
rt.block_on(async move { join_all(srvs.iter_mut().map(|srv| srv.call(()))).await });
|
rt.block_on(async move { join_all(srvs.iter_mut().map(|srv| srv.call(()))).await });
|
||||||
let elapsed = start.elapsed();
|
|
||||||
// check that at least first request succeeded
|
// check that at least first request succeeded
|
||||||
elapsed
|
start.elapsed()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,8 @@ where
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
// benchmark body
|
// benchmark body
|
||||||
rt.block_on(async move { join_all(srvs.iter_mut().map(|srv| srv.call(()))).await });
|
rt.block_on(async move { join_all(srvs.iter_mut().map(|srv| srv.call(()))).await });
|
||||||
let elapsed = start.elapsed();
|
|
||||||
// check that at least first request succeeded
|
// check that at least first request succeeded
|
||||||
elapsed
|
start.elapsed()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ where
|
||||||
/// /// Service that divides two usize values.
|
/// /// Service that divides two usize values.
|
||||||
/// async fn div((x, y): (usize, usize)) -> Result<usize, io::Error> {
|
/// async fn div((x, y): (usize, usize)) -> Result<usize, io::Error> {
|
||||||
/// if y == 0 {
|
/// if y == 0 {
|
||||||
/// Err(io::Error::new(io::ErrorKind::Other, "divide by zdro"))
|
/// Err(io::Error::new(io::ErrorKind::Other, "divide by zero"))
|
||||||
/// } else {
|
/// } else {
|
||||||
/// Ok(x / y)
|
/// Ok(x / y)
|
||||||
/// }
|
/// }
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! See [`Service`](trait.Service.html) docs for information on this crate's foundational trait.
|
||||||
|
|
||||||
#![deny(rust_2018_idioms, warnings)]
|
#![deny(rust_2018_idioms, warnings)]
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
|
|
||||||
|
@ -29,21 +31,23 @@ pub use self::map_config::{map_config, unit_config};
|
||||||
pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory};
|
pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory};
|
||||||
pub use self::transform::{apply, Transform};
|
pub use self::transform::{apply, Transform};
|
||||||
|
|
||||||
/// An asynchronous function from `Request` to a `Response`.
|
/// An asynchronous operation from `Request` to a `Response`.
|
||||||
///
|
///
|
||||||
/// `Service` represents a service that represanting interation, taking requests and giving back
|
/// The `Service` trait models a request/response interaction, receiving requests and returning
|
||||||
/// replies. You can think about service as a function with one argument and result as a return
|
/// replies. You can think about a service as a function with one argument that returns some result
|
||||||
/// type. In general form it looks like `async fn(Req) -> Result<Res, Err>`. `Service`
|
/// asynchronously. Conceptually, the operation looks like this:
|
||||||
/// trait just generalizing form of this function. Each parameter described as an assotiated type.
|
|
||||||
///
|
///
|
||||||
/// Services provides a symmetric and uniform API, same abstractions represents
|
/// ```rust,ignore
|
||||||
/// clients and servers. Services describe only `transforamtion` operation
|
/// async fn(Request) -> Result<Response, Err>
|
||||||
/// which encorouge to simplify api surface and phrases `value transformation`.
|
/// ```
|
||||||
/// That leads to simplier design of each service. That also allows better testability
|
|
||||||
/// and better composition.
|
|
||||||
///
|
///
|
||||||
/// Services could be represented in several different forms. In general,
|
/// The `Service` trait just generalizes this form where each parameter is described as an
|
||||||
/// Service is a type that implements `Service` trait.
|
/// associated type on the trait. Services can also have mutable state that influence computation.
|
||||||
|
///
|
||||||
|
/// `Service` provides a symmetric and uniform API; the same abstractions can be used to represent
|
||||||
|
/// both clients and servers. Services describe only _transformation_ operations which encourage
|
||||||
|
/// simple API surfaces. This leads to simpler design of each service, improves test-ability and
|
||||||
|
/// makes composition easier.
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
/// struct MyService;
|
/// struct MyService;
|
||||||
|
@ -52,7 +56,7 @@ pub use self::transform::{apply, Transform};
|
||||||
/// type Request = u8;
|
/// type Request = u8;
|
||||||
/// type Response = u64;
|
/// type Response = u64;
|
||||||
/// type Error = MyError;
|
/// type Error = MyError;
|
||||||
/// type Future = Pin<Box<Future<Output=Result<Self::Response, Self::Error>>>;
|
/// type Future = Pin<Box<Future<Output=Result<Self::Response, Self::Error>>>>;
|
||||||
///
|
///
|
||||||
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { ... }
|
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { ... }
|
||||||
///
|
///
|
||||||
|
@ -60,8 +64,8 @@ pub use self::transform::{apply, Transform};
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Service can have mutable state that influence computation.
|
/// Sometimes it is not necessary to implement the Service trait. For example, the above service
|
||||||
/// This service could be rewritten as a simple function:
|
/// could be rewritten as a simple function and passed to [fn_service](fn.fn_service.html).
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
/// async fn my_service(req: u8) -> Result<u64, MyError>;
|
/// async fn my_service(req: u8) -> Result<u64, MyError>;
|
||||||
|
@ -89,11 +93,9 @@ pub trait Service {
|
||||||
/// It is permitted for the service to return `Ready` from a `poll_ready`
|
/// It is permitted for the service to return `Ready` from a `poll_ready`
|
||||||
/// call and the next invocation of `call` results in an error.
|
/// call and the next invocation of `call` results in an error.
|
||||||
///
|
///
|
||||||
/// There are several notes to consider:
|
/// # Notes
|
||||||
///
|
|
||||||
/// 1. `.poll_ready()` might be called on different task from actual service call.
|
/// 1. `.poll_ready()` might be called on different task from actual service call.
|
||||||
///
|
/// 1. In case of chained services, `.poll_ready()` get called for all services at once.
|
||||||
/// 2. In case of chained services, `.poll_ready()` get called for all services at once.
|
|
||||||
fn poll_ready(&mut self, ctx: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>>;
|
fn poll_ready(&mut self, ctx: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>>;
|
||||||
|
|
||||||
/// Process the request and return the response asynchronously.
|
/// Process the request and return the response asynchronously.
|
||||||
|
@ -127,7 +129,7 @@ pub trait Service {
|
||||||
/// Map this service's error to a different error, returning a new service.
|
/// Map this service's error to a different error, returning a new service.
|
||||||
///
|
///
|
||||||
/// This function is similar to the `Result::map_err` where it will change
|
/// This function is similar to the `Result::map_err` where it will change
|
||||||
/// the error type of the underlying service. This is useful for example to
|
/// the error type of the underlying service. For example, this can be useful to
|
||||||
/// ensure that services have the same error type.
|
/// ensure that services have the same error type.
|
||||||
///
|
///
|
||||||
/// Note that this function consumes the receiving service and returns a
|
/// Note that this function consumes the receiving service and returns a
|
||||||
|
@ -141,42 +143,42 @@ pub trait Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates new `Service` values.
|
/// Factory for creating `Service`s.
|
||||||
///
|
///
|
||||||
/// Acts as a service factory. This is useful for cases where new `Service`
|
/// Acts as a service factory. This is useful for cases where new `Service`s
|
||||||
/// values must be produced. One case is a TCP server listener. The listener
|
/// must be produced. One case is a TCP server listener. The listener
|
||||||
/// accepts new TCP streams, obtains a new `Service` value using the
|
/// accepts new TCP streams, obtains a new `Service` using the
|
||||||
/// `ServiceFactory` trait, and uses that new `Service` value to process inbound
|
/// `ServiceFactory` trait, and uses the new `Service` to process inbound
|
||||||
/// requests on that new TCP stream.
|
/// requests on that new TCP stream.
|
||||||
///
|
///
|
||||||
/// `Config` is a service factory configuration type.
|
/// `Config` is a service factory configuration type.
|
||||||
pub trait ServiceFactory {
|
pub trait ServiceFactory {
|
||||||
/// Requests handled by the service.
|
/// Requests handled by the created services.
|
||||||
type Request;
|
type Request;
|
||||||
|
|
||||||
/// Responses given by the service
|
/// Responses given by the created services.
|
||||||
type Response;
|
type Response;
|
||||||
|
|
||||||
/// Errors produced by the service
|
/// Errors produced by the created services.
|
||||||
type Error;
|
type Error;
|
||||||
|
|
||||||
/// Service factory configuration
|
/// Service factory configuration.
|
||||||
type Config;
|
type Config;
|
||||||
|
|
||||||
/// The `Service` value created by this factory
|
/// The kind of `Service` created by this factory.
|
||||||
type Service: Service<
|
type Service: Service<
|
||||||
Request = Self::Request,
|
Request = Self::Request,
|
||||||
Response = Self::Response,
|
Response = Self::Response,
|
||||||
Error = Self::Error,
|
Error = Self::Error,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// Errors produced while building a service.
|
/// Errors potentially raised while building a service.
|
||||||
type InitError;
|
type InitError;
|
||||||
|
|
||||||
/// The future of the `Service` instance.
|
/// The future of the `Service` instance.
|
||||||
type Future: Future<Output = Result<Self::Service, Self::InitError>>;
|
type Future: Future<Output = Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
/// Create and return a new service value asynchronously.
|
/// Create and return a new service asynchronously.
|
||||||
fn new_service(&self, cfg: Self::Config) -> Self::Future;
|
fn new_service(&self, cfg: Self::Config) -> Self::Future;
|
||||||
|
|
||||||
/// Map this service's output to a different type, returning a new service
|
/// Map this service's output to a different type, returning a new service
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [unreleased]
|
## Unreleased
|
||||||
|
|
||||||
|
|
||||||
|
## 2.0.0-alpha.2 - 2020-08-17
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -8,6 +11,7 @@
|
||||||
* Update `tokio-rustls` dependency to 0.14
|
* Update `tokio-rustls` dependency to 0.14
|
||||||
* Update `webpki-roots` dependency to 0.20
|
* Update `webpki-roots` dependency to 0.20
|
||||||
|
|
||||||
|
|
||||||
## [2.0.0-alpha.1] - 2020-03-03
|
## [2.0.0-alpha.1] - 2020-03-03
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-tls"
|
name = "actix-tls"
|
||||||
version = "2.0.0-alpha.1"
|
version = "2.0.0-alpha.2"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix tls services"
|
description = "Actix tls services"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
|
|
@ -58,10 +58,7 @@ impl<E: PartialEq> PartialEq for TimeoutError<E> {
|
||||||
TimeoutError::Service(e2) => e1 == e2,
|
TimeoutError::Service(e2) => e1 == e2,
|
||||||
TimeoutError::Timeout => false,
|
TimeoutError::Timeout => false,
|
||||||
},
|
},
|
||||||
TimeoutError::Timeout => match other {
|
TimeoutError::Timeout => matches!(other, TimeoutError::Timeout),
|
||||||
TimeoutError::Service(_) => false,
|
|
||||||
TimeoutError::Timeout => true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ impl ResourcePath for bytestring::ByteString {
|
||||||
|
|
||||||
/// Helper trait for type that could be converted to path pattern
|
/// Helper trait for type that could be converted to path pattern
|
||||||
pub trait IntoPattern {
|
pub trait IntoPattern {
|
||||||
/// Signle patter
|
|
||||||
fn is_single(&self) -> bool;
|
fn is_single(&self) -> bool;
|
||||||
|
|
||||||
fn patterns(&self) -> Vec<String>;
|
fn patterns(&self) -> Vec<String>;
|
||||||
|
|
Loading…
Reference in New Issue