1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-16 10:18:59 +02:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Rob Ede
46bfe5de36 prepare service 2.0.0-beta.3 release 2021-01-09 14:28:33 +00:00
Rob Ede
a95afe2800 prepare router release 0.2.6 2021-01-09 14:18:20 +00:00
Rob Ede
f751cf5acb use convert err on forward_ready! (#246) 2021-01-09 14:13:16 +00:00
fakeshadow
a1982bdbad add actix-rt::task (#245) 2021-01-03 18:16:57 +00:00
Rob Ede
147c4f4f2c test bytestring with ahash 2021-01-03 04:42:08 +00:00
21 changed files with 54 additions and 42 deletions

View File

@@ -11,7 +11,7 @@ use quote::quote;
/// ///
/// ## Usage /// ## Usage
/// ///
/// ```rust /// ```
/// #[actix_rt::main] /// #[actix_rt::main]
/// async fn main() { /// async fn main() {
/// println!("Hello world"); /// println!("Hello world");

View File

@@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
## 0.2.6 - 2021-01-09
* Use `bytestring` version range compatible with Bytes v1.0. [#246]
[#246]: https://github.com/actix/actix-net/pull/246
## 0.2.5 - 2020-09-20 ## 0.2.5 - 2020-09-20
* Fix `from_hex()` method * Fix `from_hex()` method

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-router" name = "actix-router"
version = "0.2.5" version = "0.2.6"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Resource path matching library" description = "Resource path matching library"
keywords = ["actix"] keywords = ["actix"]
@@ -20,7 +20,7 @@ default = ["http"]
[dependencies] [dependencies]
regex = "1.3.1" regex = "1.3.1"
serde = "1.0.104" serde = "1.0.104"
bytestring = "0.1.2" bytestring = ">=0.1.5, <2"
log = "0.4.8" log = "0.4.8"
http = { version = "0.2.2", optional = true } http = { version = "0.2.2", optional = true }

View File

@@ -1,7 +1,9 @@
# Changes # Changes
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
* Add `task` mod with re-export of `tokio::task::{spawn_blocking, yield_now, JoinHandle}` [#245]
[#245]: https://github.com/actix/actix-net/pull/245
## 2.0.0-beta.1 - 2020-12-28 ## 2.0.0-beta.1 - 2020-12-28
### Added ### Added

View File

@@ -18,4 +18,4 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-macros = "0.1.0" actix-macros = "0.1.0"
tokio = { version = "1", features = ["rt", "net", "signal", "sync", "time"] } tokio = { version = "1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }

View File

@@ -63,3 +63,8 @@ pub mod time {
pub use tokio::time::{sleep, sleep_until, Sleep}; pub use tokio::time::{sleep, sleep_until, Sleep};
pub use tokio::time::{timeout, Timeout}; pub use tokio::time::{timeout, Timeout};
} }
/// task management.
pub mod task {
pub use tokio::task::{spawn_blocking, yield_now, JoinHandle};
}

View File

@@ -41,7 +41,7 @@ impl Runtime {
/// ///
/// # Examples /// # Examples
/// ///
/// ```rust,ignore /// ```ignore
/// # use futures::{future, Future, Stream}; /// # use futures::{future, Future, Stream};
/// use actix_rt::Runtime; /// use actix_rt::Runtime;
/// ///

View File

@@ -70,7 +70,7 @@ impl System {
/// ///
/// # Examples /// # Examples
/// ///
/// ```rust,ignore /// ```ignore
/// use tokio::{runtime::Runtime, task::LocalSet}; /// use tokio::{runtime::Runtime, task::LocalSet};
/// use actix_rt::System; /// use actix_rt::System;
/// use futures_util::future::try_join_all; /// use futures_util::future::try_join_all;
@@ -139,7 +139,7 @@ impl System {
/// ///
/// # Examples /// # Examples
/// ///
/// ```rust,ignore /// ```ignore
/// use tokio::runtime::Runtime; /// use tokio::runtime::Runtime;
/// use actix_rt::System; /// use actix_rt::System;
/// use futures_util::future::try_join_all; /// use futures_util::future::try_join_all;

View File

@@ -1,6 +1,9 @@
# Changes # Changes
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
* Hidden `ServerBuilder::start` method has been removed. Use `ServerBuilder::run`. [#246]
[#246]: https://github.com/actix/actix-net/pull/246
## 2.0.0-beta.2 - 2021-01-03 ## 2.0.0-beta.2 - 2021-01-03

View File

@@ -252,11 +252,6 @@ impl ServerBuilder {
Ok(self) Ok(self)
} }
#[doc(hidden)]
pub fn start(self) -> Server {
self.run()
}
/// Starts processing incoming connections and return server controller. /// Starts processing incoming connections and return server controller.
pub fn run(mut self) -> Server { pub fn run(mut self) -> Server {
if self.sockets.is_empty() { if self.sockets.is_empty() {

View File

@@ -12,7 +12,7 @@ use crate::{Server, ServerBuilder, ServiceFactory};
/// ///
/// # Examples /// # Examples
/// ///
/// ```rust /// ```
/// use actix_service::fn_service; /// use actix_service::fn_service;
/// use actix_server::TestServer; /// use actix_server::TestServer;
/// ///
@@ -49,10 +49,7 @@ impl TestServer {
// run server in separate thread // run server in separate thread
thread::spawn(move || { thread::spawn(move || {
let sys = System::new("actix-test-server"); let sys = System::new("actix-test-server");
factory(Server::build()) factory(Server::build()).workers(1).disable_signals().run();
.workers(1)
.disable_signals()
.start();
tx.send(System::current()).unwrap(); tx.send(System::current()).unwrap();
sys.run() sys.run()
@@ -83,7 +80,7 @@ impl TestServer {
.unwrap() .unwrap()
.workers(1) .workers(1)
.disable_signals() .disable_signals()
.start(); .run();
tx.send((System::current(), local_addr)).unwrap(); tx.send((System::current(), local_addr)).unwrap();
}); });
sys.run() sys.run()

View File

@@ -28,7 +28,7 @@ fn test_bind() {
.disable_signals() .disable_signals()
.bind("test", addr, move || fn_service(|_| ok::<_, ()>(()))) .bind("test", addr, move || fn_service(|_| ok::<_, ()>(())))
.unwrap() .unwrap()
.start() .run()
})); }));
let _ = tx.send((srv, actix_rt::System::current())); let _ = tx.send((srv, actix_rt::System::current()));
let _ = sys.run(); let _ = sys.run();
@@ -55,7 +55,7 @@ fn test_listen() {
.workers(1) .workers(1)
.listen("test", lst, move || fn_service(|_| ok::<_, ()>(()))) .listen("test", lst, move || fn_service(|_| ok::<_, ()>(())))
.unwrap() .unwrap()
.start(); .run();
let _ = tx.send(actix_rt::System::current()); let _ = tx.send(actix_rt::System::current());
}); });
let _ = sys.run(); let _ = sys.run();
@@ -94,7 +94,7 @@ fn test_start() {
}) })
}) })
.unwrap() .unwrap()
.start() .run()
})); }));
let _ = tx.send((srv, actix_rt::System::current())); let _ = tx.send((srv, actix_rt::System::current()));
@@ -173,7 +173,7 @@ fn test_configure() {
}) })
.unwrap() .unwrap()
.workers(1) .workers(1)
.start() .run()
})); }));
let _ = tx.send((srv, actix_rt::System::current())); let _ = tx.send((srv, actix_rt::System::current()));
let _ = sys.run(); let _ = sys.run();

View File

@@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
## 2.0.0-beta.3 - 2021-01-09
* The `forward_ready!` macro converts errors. [#246]
[#246]: https://github.com/actix/actix-net/pull/246
## 2.0.0-beta.2 - 2021-01-03 ## 2.0.0-beta.2 - 2021-01-03
* Remove redundant type parameter from `map_config`. * Remove redundant type parameter from `map_config`.

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "actix-service" name = "actix-service"
version = "2.0.0-beta.2" version = "2.0.0-beta.3"
authors = [ authors = [
"Nikolay Kim <fafhrd91@gmail.com>", "Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>", "Rob Ede <robjtede@icloud.com>",

View File

@@ -17,7 +17,7 @@ where
/// ///
/// # Example /// # Example
/// ///
/// ```rust /// ```
/// use std::io; /// use std::io;
/// use actix_service::{fn_factory, fn_service, Service, ServiceFactory}; /// use actix_service::{fn_factory, fn_service, Service, ServiceFactory};
/// use futures_util::future::ok; /// use futures_util::future::ok;
@@ -67,7 +67,7 @@ where
/// ///
/// # Example /// # Example
/// ///
/// ```rust /// ```
/// use std::io; /// use std::io;
/// use actix_service::{fn_factory_with_config, fn_service, Service, ServiceFactory}; /// use actix_service::{fn_factory_with_config, fn_service, Service, ServiceFactory};
/// use futures_util::future::ok; /// use futures_util::future::ok;

View File

@@ -48,7 +48,7 @@ use self::ready::{err, ok, ready, Ready};
/// replies. You can think about a service as a function with one argument that returns some result /// replies. You can think about a service as a function with one argument that returns some result
/// asynchronously. Conceptually, the operation looks like this: /// asynchronously. Conceptually, the operation looks like this:
/// ///
/// ```rust,ignore /// ```ignore
/// async fn(Request) -> Result<Response, Err> /// async fn(Request) -> Result<Response, Err>
/// ``` /// ```
/// ///
@@ -60,7 +60,7 @@ use self::ready::{err, ok, ready, Ready};
/// simple API surfaces. This leads to simpler design of each service, improves test-ability and /// simple API surfaces. This leads to simpler design of each service, improves test-ability and
/// makes composition easier. /// makes composition easier.
/// ///
/// ```rust,ignore /// ```ignore
/// struct MyService; /// struct MyService;
/// ///
/// impl Service for MyService { /// impl Service for MyService {
@@ -78,7 +78,7 @@ use self::ready::{err, ok, ready, Ready};
/// Sometimes it is not necessary to implement the Service trait. For example, the above service /// Sometimes it is not necessary to implement the Service trait. For example, the above service
/// could be rewritten as a simple function and passed to [fn_service](fn_service()). /// could be rewritten as a simple function and passed to [fn_service](fn_service()).
/// ///
/// ```rust,ignore /// ```ignore
/// async fn my_service(req: u8) -> Result<u64, MyError>; /// async fn my_service(req: u8) -> Result<u64, MyError>;
/// ``` /// ```
pub trait Service<Req> { pub trait Service<Req> {
@@ -327,7 +327,9 @@ macro_rules! forward_ready {
&mut self, &mut self,
cx: &mut ::core::task::Context<'_>, cx: &mut ::core::task::Context<'_>,
) -> ::core::task::Poll<Result<(), Self::Error>> { ) -> ::core::task::Poll<Result<(), Self::Error>> {
self.$field.poll_ready(cx) self.$field
.poll_ready(cx)
.map_err(::core::convert::Into::into)
} }
}; };
} }

View File

@@ -30,7 +30,7 @@ where
/// ///
/// For example, timeout transform: /// For example, timeout transform:
/// ///
/// ```rust,ignore /// ```ignore
/// pub struct Timeout<S> { /// pub struct Timeout<S> {
/// service: S, /// service: S,
/// timeout: Duration, /// timeout: Duration,
@@ -45,9 +45,7 @@ where
/// type Error = TimeoutError<S::Error>; /// type Error = TimeoutError<S::Error>;
/// type Future = TimeoutServiceResponse<S>; /// type Future = TimeoutServiceResponse<S>;
/// ///
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { /// actix_service::forward_ready!(service);
/// ready!(self.service.poll_ready(cx)).map_err(TimeoutError::Service)
/// }
/// ///
/// fn call(&mut self, req: S::Request) -> Self::Future { /// fn call(&mut self, req: S::Request) -> Self::Future {
/// TimeoutServiceResponse { /// TimeoutServiceResponse {
@@ -69,7 +67,7 @@ where
/// ///
/// Factory for `Timeout` middleware from the above example could look like this: /// Factory for `Timeout` middleware from the above example could look like this:
/// ///
/// ```rust,,ignore /// ```ignore
/// pub struct TimeoutTransform { /// pub struct TimeoutTransform {
/// timeout: Duration, /// timeout: Duration,
/// } /// }

View File

@@ -94,7 +94,7 @@ where
/// is passed in a reference to the request being handled by the service. /// is passed in a reference to the request being handled by the service.
/// ///
/// For example: /// For example:
/// ```rust,ignore /// ```ignore
/// let traced_service = trace( /// let traced_service = trace(
/// web_service, /// web_service,
/// |req: &Request| Some(span!(Level::INFO, "request", req.id)) /// |req: &Request| Some(span!(Level::INFO, "request", req.id))

View File

@@ -149,9 +149,7 @@ where
type Error = TimeoutError<S::Error>; type Error = TimeoutError<S::Error>;
type Future = TimeoutServiceResponse<S, Req>; type Future = TimeoutServiceResponse<S, Req>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { actix_service::forward_ready!(service);
self.service.poll_ready(cx).map_err(TimeoutError::Service)
}
fn call(&mut self, request: Req) -> Self::Future { fn call(&mut self, request: Req) -> Self::Future {
TimeoutServiceResponse { TimeoutServiceResponse {

View File

@@ -24,4 +24,4 @@ serde = { version = "1.0", optional = true }
[dev-dependencies] [dev-dependencies]
serde_json = "1.0" serde_json = "1.0"
siphasher = "0.3" ahash = { version = "0.6", default-features = false }

View File

@@ -224,7 +224,7 @@ mod test {
use alloc::borrow::ToOwned; use alloc::borrow::ToOwned;
use core::hash::{Hash, Hasher}; use core::hash::{Hash, Hasher};
use siphasher::sip::SipHasher; use ahash::AHasher;
use super::*; use super::*;
@@ -243,10 +243,10 @@ mod test {
#[test] #[test]
fn test_hash() { fn test_hash() {
let mut hasher1 = SipHasher::default(); let mut hasher1 = AHasher::default();
"str".hash(&mut hasher1); "str".hash(&mut hasher1);
let mut hasher2 = SipHasher::default(); let mut hasher2 = AHasher::default();
let s = ByteString::from_static("str"); let s = ByteString::from_static("str");
s.hash(&mut hasher2); s.hash(&mut hasher2);
assert_eq!(hasher1.finish(), hasher2.finish()); assert_eq!(hasher1.finish(), hasher2.finish());