mirror of
https://github.com/fafhrd91/actix-net
synced 2025-08-13 16:38:22 +02:00
Compare commits
3 Commits
service-v2
...
codec-v0.4
Author | SHA1 | Date | |
---|---|---|---|
|
a09f9abfcb | ||
|
e4a44b77e6 | ||
|
2ee8f45f5d |
@@ -16,16 +16,16 @@ members = [
|
||||
]
|
||||
|
||||
[patch.crates-io]
|
||||
actix-codec = { path = "actix-codec" }
|
||||
actix-codec = { git = "https://github.com/actix/actix-net.git", rev = "ba44ea7d0bafaf5fccb9a34003d503e1910943ee" }
|
||||
actix-connect = { path = "actix-connect" }
|
||||
actix-rt = { git = "https://github.com/actix/actix-net.git", rev = "ba44ea7d0bafaf5fccb9a34003d503e1910943ee" }
|
||||
actix-macros = { path = "actix-macros" }
|
||||
actix-server = { path = "actix-server" }
|
||||
actix-service = { path = "actix-service" }
|
||||
actix-service = { git = "https://github.com/actix/actix-net.git", rev = "ba44ea7d0bafaf5fccb9a34003d503e1910943ee" }
|
||||
actix-testing = { path = "actix-testing" }
|
||||
actix-threadpool = { path = "actix-threadpool" }
|
||||
actix-tls = { path = "actix-tls" }
|
||||
actix-tracing = { path = "actix-tracing" }
|
||||
actix-utils = { path = "actix-utils" }
|
||||
actix-utils = { git = "https://github.com/actix/actix-net.git", rev = "ba44ea7d0bafaf5fccb9a34003d503e1910943ee" }
|
||||
actix-router = { path = "router" }
|
||||
bytestring = { path = "string" }
|
||||
|
@@ -1,14 +1,25 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2020-xx-xx
|
||||
* Upgrade `pin-project` to `1.0`.
|
||||
|
||||
|
||||
## 0.4.0-beta.1 - 2020-12-28
|
||||
* Replace `pin-project` with `pin-project-lite`. [#237]
|
||||
* Upgrade `tokio` dependency to `1`. [#237]
|
||||
* Upgrade `tokio-util` dependency to `0.6`. [#237]
|
||||
* Upgrade `bytes` dependency to `1`. [#237]
|
||||
|
||||
[#237]: https://github.com/actix/actix-net/pull/237
|
||||
|
||||
|
||||
## 0.3.0 - 2020-08-23
|
||||
* No changes from beta 2.
|
||||
|
||||
|
||||
## 0.3.0-beta.2 - 2020-08-19
|
||||
* Remove unused type parameter from `Framed::replace_codec`.
|
||||
|
||||
|
||||
## 0.3.0-beta.1 - 2020-08-19
|
||||
* Use `.advance()` instead of `.split_to()`.
|
||||
* Upgrade `tokio-util` to `0.3`.
|
||||
@@ -18,32 +29,31 @@
|
||||
* Add method on `Framed` to get a pinned reference to the underlying I/O.
|
||||
* Add method on `Framed` check emptiness of read buffer.
|
||||
|
||||
## [0.2.0] - 2019-12-10
|
||||
|
||||
## 0.2.0 - 2019-12-10
|
||||
* Use specific futures dependencies
|
||||
|
||||
## [0.2.0-alpha.4]
|
||||
|
||||
## 0.2.0-alpha.4
|
||||
* Fix buffer remaining capacity calculation
|
||||
|
||||
## [0.2.0-alpha.3]
|
||||
|
||||
## 0.2.0-alpha.3
|
||||
* Use tokio 0.2
|
||||
|
||||
* Fix low/high watermark for write/read buffers
|
||||
|
||||
## [0.2.0-alpha.2]
|
||||
|
||||
## 0.2.0-alpha.2
|
||||
* Migrated to `std::future`
|
||||
|
||||
## [0.1.2] - 2019-03-27
|
||||
|
||||
## 0.1.2 - 2019-03-27
|
||||
* Added `Framed::map_io()` method.
|
||||
|
||||
## [0.1.1] - 2019-03-06
|
||||
|
||||
## 0.1.1 - 2019-03-06
|
||||
* Added `FramedParts::with_read_buffer()` method.
|
||||
|
||||
## [0.1.0] - 2018-12-09
|
||||
|
||||
## 0.1.0 - 2018-12-09
|
||||
* Move codec to separate crate
|
||||
|
@@ -1,8 +1,8 @@
|
||||
[package]
|
||||
name = "actix-codec"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0-beta.1"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Codec utilities for working with framed protocols."
|
||||
description = "Codec utilities for working with framed protocols"
|
||||
keywords = ["network", "framework", "async", "futures"]
|
||||
homepage = "https://actix.rs"
|
||||
repository = "https://github.com/actix/actix-net.git"
|
||||
@@ -17,10 +17,10 @@ path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
bytes = "0.5.2"
|
||||
futures-core = { version = "0.3.4", default-features = false }
|
||||
futures-sink = { version = "0.3.4", default-features = false }
|
||||
bytes = "1"
|
||||
futures-core = { version = "0.3.7", default-features = false }
|
||||
futures-sink = { version = "0.3.7", default-features = false }
|
||||
log = "0.4"
|
||||
pin-project = "1.0.0"
|
||||
tokio = { version = "0.2.5", default-features = false }
|
||||
tokio-util = { version = "0.3.1", default-features = false, features = ["codec"] }
|
||||
pin-project-lite = "0.2"
|
||||
tokio = "1"
|
||||
tokio-util = { version = "0.6", features = ["codec", "io"] }
|
||||
|
@@ -14,7 +14,7 @@ impl Encoder<Bytes> for BytesCodec {
|
||||
|
||||
#[inline]
|
||||
fn encode(&mut self, item: Bytes, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
||||
dst.extend_from_slice(item.bytes());
|
||||
dst.extend_from_slice(item.chunk());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ use std::{fmt, io};
|
||||
use bytes::{Buf, BytesMut};
|
||||
use futures_core::{ready, Stream};
|
||||
use futures_sink::Sink;
|
||||
use pin_project::pin_project;
|
||||
|
||||
use crate::{AsyncRead, AsyncWrite, Decoder, Encoder};
|
||||
|
||||
@@ -21,22 +20,23 @@ bitflags::bitflags! {
|
||||
}
|
||||
}
|
||||
|
||||
/// A unified `Stream` and `Sink` interface to an underlying I/O object, using
|
||||
/// the `Encoder` and `Decoder` traits to encode and decode frames.
|
||||
///
|
||||
/// Raw I/O objects work with byte sequences, but higher-level code usually
|
||||
/// wants to batch these into meaningful chunks, called "frames". This
|
||||
/// method layers framing on top of an I/O object, by using the `Encoder`/`Decoder`
|
||||
/// traits to handle encoding and decoding of message frames. Note that
|
||||
/// the incoming and outgoing frame types may be distinct.
|
||||
#[pin_project]
|
||||
pub struct Framed<T, U> {
|
||||
#[pin]
|
||||
io: T,
|
||||
codec: U,
|
||||
flags: Flags,
|
||||
read_buf: BytesMut,
|
||||
write_buf: BytesMut,
|
||||
pin_project_lite::pin_project! {
|
||||
/// A unified `Stream` and `Sink` interface to an underlying I/O object, using
|
||||
/// the `Encoder` and `Decoder` traits to encode and decode frames.
|
||||
///
|
||||
/// Raw I/O objects work with byte sequences, but higher-level code usually
|
||||
/// wants to batch these into meaningful chunks, called "frames". This
|
||||
/// method layers framing on top of an I/O object, by using the `Encoder`/`Decoder`
|
||||
/// traits to handle encoding and decoding of message frames. Note that
|
||||
/// the incoming and outgoing frame types may be distinct.
|
||||
pub struct Framed<T, U> {
|
||||
#[pin]
|
||||
io: T,
|
||||
codec: U,
|
||||
flags: Flags,
|
||||
read_buf: BytesMut,
|
||||
write_buf: BytesMut,
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, U> Framed<T, U>
|
||||
@@ -220,7 +220,8 @@ impl<T, U> Framed<T, U> {
|
||||
if remaining < LW {
|
||||
this.read_buf.reserve(HW - remaining)
|
||||
}
|
||||
let cnt = match this.io.poll_read_buf(cx, &mut this.read_buf) {
|
||||
|
||||
let cnt = match tokio_util::io::poll_read_buf(this.io, cx, this.read_buf) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
Poll::Ready(Err(e)) => return Poll::Ready(Some(Err(e.into()))),
|
||||
Poll::Ready(Ok(cnt)) => cnt,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
//! Utilities for encoding and decoding frames.
|
||||
//! Codec utilities for working with framed protocols.
|
||||
//!
|
||||
//! Contains adapters to go from streams of bytes, [`AsyncRead`] and
|
||||
//! [`AsyncWrite`], to framed streams implementing [`Sink`] and [`Stream`].
|
||||
@@ -18,5 +18,6 @@ mod framed;
|
||||
pub use self::bcodec::BytesCodec;
|
||||
pub use self::framed::{Framed, FramedParts};
|
||||
|
||||
pub use tokio::io::{AsyncRead, AsyncWrite};
|
||||
pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
pub use tokio_util::codec::{Decoder, Encoder};
|
||||
pub use tokio_util::io::poll_read_buf;
|
||||
|
@@ -1,226 +1,156 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2020-xx-xx
|
||||
|
||||
|
||||
## 3.0.0-beta.1 - 2020-12-28
|
||||
* Update `bytes` dependency to `1`. [#237]
|
||||
* Use `pin-project-lite` to replace `pin-project`. [#229]
|
||||
* Remove `condition`,`either`,`inflight`,`keepalive`,`oneshot`,`order`,`stream` and `time` mods. [#229]
|
||||
|
||||
[#229]: https://github.com/actix/actix-net/pull/229
|
||||
[#237]: https://github.com/actix/actix-net/pull/237
|
||||
|
||||
|
||||
## 2.0.0 - 2020-08-23
|
||||
* No changes from beta 1.
|
||||
|
||||
|
||||
## 2.0.0-beta.1 - 2020-08-19
|
||||
* Upgrade `tokio-util` to `0.3`.
|
||||
* Remove unsound custom Cell and use `std::cell::RefCell` instead, as well as `actix-service`.
|
||||
* Rename method to correctly spelled `LocalWaker::is_registered`.
|
||||
|
||||
## [1.0.6] - 2020-01-08
|
||||
|
||||
* Add `Clone` impl for `condition::Waiter`
|
||||
## 1.0.6 - 2020-01-08
|
||||
* Add `Clone` impl for `condition::Waiter`.
|
||||
|
||||
## [1.0.5] - 2020-01-08
|
||||
|
||||
## 1.0.5 - 2020-01-08
|
||||
* Add `Condition` type.
|
||||
|
||||
* Add `Pool` of one-shot's.
|
||||
|
||||
## [1.0.4] - 2019-12-20
|
||||
|
||||
## 1.0.4 - 2019-12-20
|
||||
* Add methods to check `LocalWaker` registration state.
|
||||
|
||||
## [1.0.3] - 2019-12-11
|
||||
|
||||
## 1.0.3 - 2019-12-11
|
||||
* Revert InOrder service changes
|
||||
|
||||
## [1.0.2] - 2019-12-11
|
||||
|
||||
* Allow to create `framed::Dispatcher` with custom `mpsc::Receiver`
|
||||
## 1.0.2 - 2019-12-11
|
||||
* Allow to create `framed::Dispatcher` with custom `mpsc::Receiver`.
|
||||
* Add `oneshot::Sender::is_canceled()` method.
|
||||
|
||||
* Add `oneshot::Sender::is_canceled()` method
|
||||
|
||||
## [1.0.1] - 2019-12-11
|
||||
## 1.0.1 - 2019-12-11
|
||||
* Optimize InOrder service.
|
||||
|
||||
* Optimize InOrder service
|
||||
|
||||
## [1.0.0] - 2019-12-11
|
||||
## 1.0.0 - 2019-12-11
|
||||
* Simplify oneshot and mpsc implementations.
|
||||
|
||||
* Simplify oneshot and mpsc implementations
|
||||
|
||||
## [1.0.0-alpha.3] - 2019-12-07
|
||||
## 1.0.0-alpha.3 - 2019-12-07
|
||||
* Migrate to tokio 0.2.
|
||||
* Fix oneshot.
|
||||
|
||||
* Migrate to tokio 0.2
|
||||
|
||||
* Fix oneshot
|
||||
## 1.0.0-alpha.2 - 2019-12-02
|
||||
* Migrate to `std::future`.
|
||||
|
||||
## [1.0.0-alpha.2] - 2019-12-02
|
||||
|
||||
* Migrate to `std::future`
|
||||
|
||||
## [0.4.7] - 2019-10-14
|
||||
|
||||
## 0.4.7 - 2019-10-14
|
||||
* Re-register task on every framed transport poll.
|
||||
|
||||
|
||||
## [0.4.6] - 2019-10-08
|
||||
|
||||
## 0.4.6 - 2019-10-08
|
||||
* Refactor `Counter` type. register current task in available method.
|
||||
|
||||
|
||||
## [0.4.5] - 2019-07-19
|
||||
|
||||
### Removed
|
||||
|
||||
* Deprecated `CloneableService` as it is not safe
|
||||
## 0.4.5 - 2019-07-19
|
||||
* Deprecated `CloneableService` as it is not safe.
|
||||
|
||||
|
||||
## [0.4.4] - 2019-07-17
|
||||
|
||||
### Changed
|
||||
|
||||
* Undeprecate `FramedTransport` as it is actually useful
|
||||
## 0.4.4 - 2019-07-17
|
||||
* Undeprecate `FramedTransport` as it is actually useful.
|
||||
|
||||
|
||||
## [0.4.3] - 2019-07-17
|
||||
|
||||
### Deprecated
|
||||
|
||||
* Deprecate `CloneableService` as it is not safe and in general not very useful
|
||||
|
||||
* Deprecate `FramedTransport` in favor of `actix-ioframe`
|
||||
## 0.4.3 - 2019-07-17
|
||||
* Deprecate `CloneableService` as it is not safe and in general not very useful.
|
||||
* Deprecate `FramedTransport` in favor of `actix-ioframe`.
|
||||
|
||||
|
||||
## [0.4.2] - 2019-06-26
|
||||
|
||||
### Fixed
|
||||
|
||||
* Do not block on sink drop for FramedTransport
|
||||
## 0.4.2 - 2019-06-26
|
||||
* Do not block on sink drop for FramedTransport.
|
||||
|
||||
|
||||
## [0.4.1] - 2019-05-15
|
||||
|
||||
### Changed
|
||||
|
||||
* Change `Either` constructor
|
||||
## 0.4.1 - 2019-05-15
|
||||
* Change `Either` constructor.
|
||||
|
||||
|
||||
## [0.4.0] - 2019-05-11
|
||||
## 0.4.0 - 2019-05-11
|
||||
* Change `Either` to handle two nexted services.
|
||||
* Upgrade actix-service 0.4.
|
||||
* Removed framed related services.
|
||||
* Removed stream related services.
|
||||
|
||||
### Changed
|
||||
|
||||
* Change `Either` to handle two nexted services
|
||||
|
||||
* Upgrade actix-service 0.4
|
||||
|
||||
### Deleted
|
||||
|
||||
* Framed related services
|
||||
|
||||
* Stream related services
|
||||
|
||||
## [0.3.5] - 2019-04-04
|
||||
|
||||
### Added
|
||||
|
||||
## 0.3.5 - 2019-04-04
|
||||
* Allow to send messages to `FramedTransport` via mpsc channel.
|
||||
|
||||
### Changed
|
||||
|
||||
* Remove 'static constraint from Clonable service
|
||||
* Remove `'static` constraint from Clonable service.
|
||||
|
||||
|
||||
## [0.3.4] - 2019-03-12
|
||||
|
||||
### Changed
|
||||
|
||||
## 0.3.4 - 2019-03-12
|
||||
* `TimeoutService`, `InOrderService`, `InFlightService` accepts generic IntoService services.
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix `InFlightService::poll_ready()` nested service readiness check
|
||||
|
||||
* Fix `InOrderService::poll_ready()` nested service readiness check
|
||||
* Fix `InFlightService::poll_ready()` nested service readiness check.
|
||||
* Fix `InOrderService::poll_ready()` nested service readiness check.
|
||||
|
||||
|
||||
## [0.3.3] - 2019-03-09
|
||||
|
||||
### Changed
|
||||
|
||||
* Revert IntoFuture change
|
||||
|
||||
* Add generic config param for IntoFramed and TakeOne new services
|
||||
## 0.3.3 - 2019-03-09
|
||||
* Revert IntoFuture change.
|
||||
* Add generic config param for IntoFramed and TakeOne new services.
|
||||
|
||||
|
||||
## [0.3.2] - 2019-03-04
|
||||
## 0.3.2 - 2019-03-04
|
||||
* Use IntoFuture for new services.
|
||||
|
||||
### Changed
|
||||
|
||||
* Use IntoFuture for new services
|
||||
## 0.3.1 - 2019-03-04
|
||||
* Use new type of transform trait.
|
||||
|
||||
|
||||
## [0.3.1] - 2019-03-04
|
||||
|
||||
### Changed
|
||||
|
||||
* Use new type of transform trait
|
||||
|
||||
|
||||
## [0.3.0] - 2019-03-02
|
||||
|
||||
### Changed
|
||||
|
||||
## 0.3.0 - 2019-03-02
|
||||
* Use new `NewService` trait
|
||||
|
||||
* BoxedNewService` and `BoxedService` types moved to actix-service crate.
|
||||
|
||||
|
||||
## [0.2.4] - 2019-02-21
|
||||
|
||||
### Changed
|
||||
|
||||
## 0.2.4 - 2019-02-21
|
||||
* Custom `BoxedNewService` implementation.
|
||||
|
||||
|
||||
## [0.2.3] - 2019-02-21
|
||||
|
||||
### Added
|
||||
|
||||
* Add `BoxedNewService` and `BoxedService`
|
||||
## 0.2.3 - 2019-02-21
|
||||
* Add `BoxedNewService` and `BoxedService`.
|
||||
|
||||
|
||||
## [0.2.2] - 2019-02-11
|
||||
|
||||
### Added
|
||||
|
||||
* Add `Display` impl for `TimeoutError`
|
||||
|
||||
* Add `Display` impl for `InOrderError`
|
||||
## 0.2.2 - 2019-02-11
|
||||
* Add `Display` impl for `TimeoutError`.
|
||||
* Add `Display` impl for `InOrderError`.
|
||||
|
||||
|
||||
## [0.2.1] - 2019-02-06
|
||||
|
||||
### Added
|
||||
|
||||
## 0.2.1 - 2019-02-06
|
||||
* Add `InOrder` service. the service yields responses as they become available,
|
||||
in the order that their originating requests were submitted to the service.
|
||||
|
||||
### Changed
|
||||
|
||||
* Convert `Timeout` and `InFlight` services to a transforms
|
||||
* Convert `Timeout` and `InFlight` services to a transforms.
|
||||
|
||||
|
||||
## [0.2.0] - 2019-02-01
|
||||
|
||||
* Fix framed transport error handling
|
||||
|
||||
* Added Clone impl for Either service
|
||||
|
||||
* Added Clone impl for Timeout service factory
|
||||
|
||||
* Added Service and NewService for Stream dispatcher
|
||||
|
||||
* Switch to actix-service 0.2
|
||||
## 0.2.0 - 2019-02-01
|
||||
* Fix framed transport error handling.
|
||||
* Added Clone impl for Either service.
|
||||
* Added Clone impl for Timeout service factory.
|
||||
* Added Service and NewService for Stream dispatcher.
|
||||
* Switch to actix-service 0.2.
|
||||
|
||||
|
||||
## [0.1.0] - 2018-12-09
|
||||
|
||||
* Move utils services to separate crate
|
||||
## 0.1.0 - 2018-12-09
|
||||
* Move utils services to separate crate.
|
||||
|
@@ -1,8 +1,8 @@
|
||||
[package]
|
||||
name = "actix-utils"
|
||||
version = "2.0.0"
|
||||
version = "3.0.0-beta.1"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Various network related services and utilities for the Actix ecosystem."
|
||||
description = "Various network related services and utilities for the Actix ecosystem"
|
||||
keywords = ["network", "framework", "async", "futures"]
|
||||
homepage = "https://actix.rs"
|
||||
repository = "https://github.com/actix/actix-net.git"
|
||||
@@ -16,9 +16,9 @@ name = "actix_utils"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
actix-codec = "0.3.0"
|
||||
actix-rt = "1.1.1"
|
||||
actix-service = "1.0.6"
|
||||
actix-codec = "0.4.0-beta.1"
|
||||
actix-rt = "2.0.0-beta.1"
|
||||
actix-service = "2.0.0-beta.1"
|
||||
|
||||
futures-core = { version = "0.3.7", default-features = false }
|
||||
futures-sink = { version = "0.3.7", default-features = false }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
//! Actix utils - various helper services
|
||||
//! Various network related services and utilities for the Actix ecosystem.
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
|
@@ -1,4 +1,5 @@
|
||||
//! A multi-producer, single-consumer, futures-aware, FIFO queue.
|
||||
|
||||
use core::any::Any;
|
||||
use core::cell::RefCell;
|
||||
use core::fmt;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
//! Service that applies a timeout to requests.
|
||||
//!
|
||||
//! If the response does not complete within the specified timeout, the response
|
||||
//! will be aborted.
|
||||
//! If the response does not complete within the specified timeout, the response will be aborted.
|
||||
|
||||
use core::future::Future;
|
||||
use core::marker::PhantomData;
|
||||
@@ -9,7 +8,7 @@ use core::pin::Pin;
|
||||
use core::task::{Context, Poll};
|
||||
use core::{fmt, time};
|
||||
|
||||
use actix_rt::time::{delay_for, Delay};
|
||||
use actix_rt::time::{sleep, Sleep};
|
||||
use actix_service::{IntoService, Service, Transform};
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
@@ -85,8 +84,8 @@ where
|
||||
{
|
||||
type Response = S::Response;
|
||||
type Error = TimeoutError<S::Error>;
|
||||
type InitError = E;
|
||||
type Transform = TimeoutService<S, Req>;
|
||||
type InitError = E;
|
||||
type Future = TimeoutFuture<Self::Transform, Self::InitError>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
@@ -157,7 +156,7 @@ where
|
||||
fn call(&mut self, request: Req) -> Self::Future {
|
||||
TimeoutServiceResponse {
|
||||
fut: self.service.call(request),
|
||||
sleep: delay_for(self.timeout),
|
||||
sleep: sleep(self.timeout),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +170,8 @@ pin_project! {
|
||||
{
|
||||
#[pin]
|
||||
fut: S::Future,
|
||||
sleep: Delay,
|
||||
#[pin]
|
||||
sleep: Sleep,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,20 +193,18 @@ where
|
||||
}
|
||||
|
||||
// Now check the sleep
|
||||
Pin::new(this.sleep)
|
||||
.poll(cx)
|
||||
.map(|_| Err(TimeoutError::Timeout))
|
||||
this.sleep.poll(cx).map(|_| Err(TimeoutError::Timeout))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::task::Poll;
|
||||
use std::time::Duration;
|
||||
use core::task::Poll;
|
||||
use core::time::Duration;
|
||||
|
||||
use super::*;
|
||||
use actix_service::{apply, fn_factory, Service, ServiceFactory};
|
||||
use futures_util::future::{ok, FutureExt, LocalBoxFuture};
|
||||
use futures_core::future::LocalBoxFuture;
|
||||
|
||||
struct SleepService(Duration);
|
||||
|
||||
@@ -218,9 +216,11 @@ mod tests {
|
||||
actix_service::always_ready!();
|
||||
|
||||
fn call(&mut self, _: ()) -> Self::Future {
|
||||
actix_rt::time::delay_for(self.0)
|
||||
.then(|_| ok::<_, ()>(()))
|
||||
.boxed_local()
|
||||
let sleep = actix_rt::time::sleep(self.0);
|
||||
Box::pin(async move {
|
||||
sleep.await;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ mod tests {
|
||||
|
||||
let timeout = apply(
|
||||
Timeout::new(resolution),
|
||||
fn_factory(|| ok::<_, ()>(SleepService(wait_time))),
|
||||
fn_factory(|| async { Ok::<_, ()>(SleepService(wait_time)) }),
|
||||
);
|
||||
let mut srv = timeout.new_service(&()).await.unwrap();
|
||||
|
||||
|
Reference in New Issue
Block a user