mirror of
https://github.com/fafhrd91/actix-net
synced 2025-01-29 21:52:35 +01:00
use IntoService types for transform services
This commit is contained in:
parent
825117fd4c
commit
755d4958c5
@ -1,5 +1,11 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.3.4] - 2019-03-12
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* `TimeoutService`, `InOrderService`, `InFlightService` accepts generic IntoService services.
|
||||||
|
|
||||||
## [0.3.3] - 2019-03-09
|
## [0.3.3] - 2019-03-09
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-utils"
|
name = "actix-utils"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix utils - various actix net related services"
|
description = "Actix utils - various actix net related services"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use actix_service::{Service, Transform, Void};
|
use actix_service::{IntoService, Service, Transform, Void};
|
||||||
use futures::future::{ok, FutureResult};
|
use futures::future::{ok, FutureResult};
|
||||||
use futures::{Async, Future, Poll};
|
use futures::{Async, Future, Poll};
|
||||||
|
|
||||||
@ -42,11 +42,17 @@ pub struct InFlightService<S> {
|
|||||||
service: S,
|
service: S,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> InFlightService<S> {
|
impl<S> InFlightService<S>
|
||||||
pub fn new(max: usize, service: S) -> Self {
|
where
|
||||||
|
S: Service,
|
||||||
|
{
|
||||||
|
pub fn new<U>(max: usize, service: U) -> Self
|
||||||
|
where
|
||||||
|
U: IntoService<S>,
|
||||||
|
{
|
||||||
Self {
|
Self {
|
||||||
service,
|
|
||||||
count: Counter::new(max),
|
count: Counter::new(max),
|
||||||
|
service: service.into_service(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use std::fmt;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use actix_service::{Service, Transform, Void};
|
use actix_service::{IntoService, Service, Transform, Void};
|
||||||
use futures::future::{ok, FutureResult};
|
use futures::future::{ok, FutureResult};
|
||||||
use futures::task::AtomicTask;
|
use futures::task::AtomicTask;
|
||||||
use futures::unsync::oneshot;
|
use futures::unsync::oneshot;
|
||||||
@ -112,9 +112,12 @@ where
|
|||||||
S::Future: 'static,
|
S::Future: 'static,
|
||||||
S::Error: 'static,
|
S::Error: 'static,
|
||||||
{
|
{
|
||||||
pub fn new(service: S) -> Self {
|
pub fn new<U>(service: U) -> Self
|
||||||
|
where
|
||||||
|
U: IntoService<S>,
|
||||||
|
{
|
||||||
Self {
|
Self {
|
||||||
service,
|
service: service.into_service(),
|
||||||
acks: VecDeque::new(),
|
acks: VecDeque::new(),
|
||||||
task: Rc::new(AtomicTask::new()),
|
task: Rc::new(AtomicTask::new()),
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use std::fmt;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{IntoService, Service, Transform};
|
||||||
use futures::future::{ok, FutureResult};
|
use futures::future::{ok, FutureResult};
|
||||||
use futures::{Async, Future, Poll};
|
use futures::{Async, Future, Poll};
|
||||||
use tokio_timer::{clock, Delay};
|
use tokio_timer::{clock, Delay};
|
||||||
@ -106,9 +106,18 @@ pub struct TimeoutService<S> {
|
|||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> TimeoutService<S> {
|
impl<S> TimeoutService<S>
|
||||||
pub fn new(timeout: Duration, service: S) -> Self {
|
where
|
||||||
TimeoutService { service, timeout }
|
S: Service,
|
||||||
|
{
|
||||||
|
pub fn new<U>(timeout: Duration, service: U) -> Self
|
||||||
|
where
|
||||||
|
U: IntoService<S>,
|
||||||
|
{
|
||||||
|
TimeoutService {
|
||||||
|
timeout,
|
||||||
|
service: service.into_service(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user