mirror of https://github.com/fafhrd91/actix-net
Merge branch 'master' into actix-rt
This commit is contained in:
commit
06de8af2b2
|
@ -31,4 +31,4 @@ jobs:
|
|||
uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --all-features --all --tests
|
||||
args: --workspace --tests
|
||||
|
|
|
@ -53,20 +53,20 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
args: --workspace --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
timeout-minutes: 40
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features --no-fail-fast -- --nocapture
|
||||
args: --workspace --exclude=actix-tls --no-fail-fast -- --nocapture
|
||||
|
||||
- name: Generate coverage file
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
run: |
|
||||
cargo install cargo-tarpaulin
|
||||
cargo tarpaulin --out Xml --workspace --all-features
|
||||
cargo tarpaulin --out Xml --workspace
|
||||
|
||||
- name: Upload to Codecov
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
|
|
|
@ -34,10 +34,10 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
args: --workspace --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features --no-fail-fast -- --nocapture
|
||||
args: --workspace --exclude=actix-tls --no-fail-fast -- --nocapture
|
||||
|
|
|
@ -42,4 +42,4 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
args: --workspace --bins --examples --tests
|
||||
|
|
|
@ -60,10 +60,10 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
args: --workspace --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features --no-fail-fast -- --nocapture
|
||||
args: --workspace --exclude=actix-tls --no-fail-fast -- --nocapture
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
//! [`Sink`]: futures_sink::Sink
|
||||
//! [`Stream`]: futures_core::Stream
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![warn(missing_docs)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
mod bcodec;
|
||||
mod framed;
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
//! * `openssl` - enables TLS support via `openssl` crate
|
||||
//! * `rustls` - enables TLS support via `rustls` crate
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![recursion_limit = "128"]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# CHANGES
|
||||
|
||||
## 0.1.3 - 2020-12-3
|
||||
|
||||
* Add `actix-reexport` feature
|
||||
|
||||
## 0.1.2 - 2020-05-18
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "actix-macros"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix runtime macros"
|
||||
repository = "https://github.com/actix/actix-net"
|
||||
|
@ -16,6 +16,9 @@ proc-macro = true
|
|||
quote = "1.0.3"
|
||||
syn = { version = "^1", features = ["full"] }
|
||||
|
||||
[features]
|
||||
actix-reexport = []
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1.0"
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
//! Macros for use with Tokio
|
||||
extern crate proc_macro;
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
|
@ -33,14 +36,25 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
|
|||
|
||||
sig.asyncness = None;
|
||||
|
||||
(quote! {
|
||||
#(#attrs)*
|
||||
#vis #sig {
|
||||
actix_rt::System::new(stringify!(#name))
|
||||
.block_on(async move { #body })
|
||||
}
|
||||
})
|
||||
.into()
|
||||
if cfg!(feature = "actix-reexport") {
|
||||
(quote! {
|
||||
#(#attrs)*
|
||||
#vis #sig {
|
||||
actix::System::new(stringify!(#name))
|
||||
.block_on(async move { #body })
|
||||
}
|
||||
})
|
||||
.into()
|
||||
} else {
|
||||
(quote! {
|
||||
#(#attrs)*
|
||||
#vis #sig {
|
||||
actix_rt::System::new(stringify!(#name))
|
||||
.block_on(async move { #body })
|
||||
}
|
||||
})
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Marks async test function to be executed by actix runtime.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
//! A runtime implementation that runs everything on the current thread.
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
## Unreleased - 2020-xx-xx
|
||||
* Added explicit info log message on accept queue pause. [#215]
|
||||
* Prevent double registration of sockets when back-pressure is resolved. [#223]
|
||||
|
||||
[#215]: https://github.com/actix/actix-net/pull/215
|
||||
[#223]: https://github.com/actix/actix-net/pull/223
|
||||
|
||||
|
||||
## 1.0.4 - 2020-09-12
|
||||
|
|
|
@ -370,6 +370,11 @@ impl Accept {
|
|||
if !on {
|
||||
self.backpressure = false;
|
||||
for (token, info) in self.sockets.iter() {
|
||||
if info.timeout.is_some() {
|
||||
// socket will attempt to re-register itself when its timeout completes
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Err(err) = self.register(token, info) {
|
||||
error!("Can not resume socket accept process: {}", err);
|
||||
} else {
|
||||
|
|
|
@ -8,10 +8,9 @@ use futures_util::future::{ok, Future, FutureExt, LocalBoxFuture};
|
|||
use log::error;
|
||||
|
||||
use super::builder::bind_addr;
|
||||
use super::service::{
|
||||
BoxedServerService, InternalServiceFactory, ServerMessage, StreamService,
|
||||
};
|
||||
use super::service::{BoxedServerService, InternalServiceFactory, StreamService};
|
||||
use super::Token;
|
||||
use crate::socket::StdStream;
|
||||
|
||||
pub struct ServiceConfig {
|
||||
pub(crate) services: Vec<(String, net::TcpListener)>,
|
||||
|
@ -239,7 +238,7 @@ impl ServiceRuntime {
|
|||
|
||||
type BoxedNewService = Box<
|
||||
dyn actix::ServiceFactory<
|
||||
Request = (Option<CounterGuard>, ServerMessage),
|
||||
Request = (Option<CounterGuard>, StdStream),
|
||||
Response = (),
|
||||
Error = (),
|
||||
InitError = (),
|
||||
|
@ -261,12 +260,12 @@ where
|
|||
T::Error: 'static,
|
||||
T::InitError: fmt::Debug + 'static,
|
||||
{
|
||||
type Request = (Option<CounterGuard>, ServerMessage);
|
||||
type Request = (Option<CounterGuard>, StdStream);
|
||||
type Response = ();
|
||||
type Error = ();
|
||||
type InitError = ();
|
||||
type Config = ();
|
||||
type Service = BoxedServerService;
|
||||
type InitError = ();
|
||||
type Future = LocalBoxFuture<'static, Result<BoxedServerService, ()>>;
|
||||
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
//! General purpose TCP server.
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
mod accept;
|
||||
mod builder;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::net::SocketAddr;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_rt::spawn;
|
||||
use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory};
|
||||
|
@ -13,18 +12,6 @@ use log::error;
|
|||
use super::Token;
|
||||
use crate::socket::{FromStream, StdStream};
|
||||
|
||||
/// Server message
|
||||
pub(crate) enum ServerMessage {
|
||||
/// New stream
|
||||
Connect(StdStream),
|
||||
|
||||
/// Gracefully shutdown
|
||||
Shutdown(Duration),
|
||||
|
||||
/// Force shutdown
|
||||
ForceShutdown,
|
||||
}
|
||||
|
||||
pub trait ServiceFactory<Stream: FromStream>: Send + Clone + 'static {
|
||||
type Factory: actix::ServiceFactory<Config = (), Request = Stream>;
|
||||
|
||||
|
@ -41,7 +28,7 @@ pub(crate) trait InternalServiceFactory: Send {
|
|||
|
||||
pub(crate) type BoxedServerService = Box<
|
||||
dyn Service<
|
||||
Request = (Option<CounterGuard>, ServerMessage),
|
||||
Request = (Option<CounterGuard>, StdStream),
|
||||
Response = (),
|
||||
Error = (),
|
||||
Future = Ready<Result<(), ()>>,
|
||||
|
@ -65,7 +52,7 @@ where
|
|||
T::Error: 'static,
|
||||
I: FromStream,
|
||||
{
|
||||
type Request = (Option<CounterGuard>, ServerMessage);
|
||||
type Request = (Option<CounterGuard>, StdStream);
|
||||
type Response = ();
|
||||
type Error = ();
|
||||
type Future = Ready<Result<(), ()>>;
|
||||
|
@ -74,25 +61,20 @@ where
|
|||
self.service.poll_ready(ctx).map_err(|_| ())
|
||||
}
|
||||
|
||||
fn call(&mut self, (guard, req): (Option<CounterGuard>, ServerMessage)) -> Self::Future {
|
||||
match req {
|
||||
ServerMessage::Connect(stream) => {
|
||||
let stream = FromStream::from_stdstream(stream).map_err(|e| {
|
||||
error!("Can not convert to an async tcp stream: {}", e);
|
||||
fn call(&mut self, (guard, req): (Option<CounterGuard>, StdStream)) -> Self::Future {
|
||||
match FromStream::from_stdstream(req) {
|
||||
Ok(stream) => {
|
||||
let f = self.service.call(stream);
|
||||
spawn(async move {
|
||||
let _ = f.await;
|
||||
drop(guard);
|
||||
});
|
||||
|
||||
if let Ok(stream) = stream {
|
||||
let f = self.service.call(stream);
|
||||
spawn(async move {
|
||||
let _ = f.await;
|
||||
drop(guard);
|
||||
});
|
||||
ok(())
|
||||
} else {
|
||||
err(())
|
||||
}
|
||||
ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Can not convert to an async tcp stream: {}", e);
|
||||
err(())
|
||||
}
|
||||
_ => ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,20 +141,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl InternalServiceFactory for Box<dyn InternalServiceFactory> {
|
||||
fn name(&self, token: Token) -> &str {
|
||||
self.as_ref().name(token)
|
||||
}
|
||||
|
||||
fn clone_factory(&self) -> Box<dyn InternalServiceFactory> {
|
||||
self.as_ref().clone_factory()
|
||||
}
|
||||
|
||||
fn create(&self) -> LocalBoxFuture<'static, Result<Vec<(Token, BoxedServerService)>, ()>> {
|
||||
self.as_ref().create()
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, T, I> ServiceFactory<I> for F
|
||||
where
|
||||
F: Fn() -> T + Send + Clone + 'static,
|
||||
|
|
|
@ -14,7 +14,7 @@ use futures_util::{future::Future, stream::Stream, FutureExt, TryFutureExt};
|
|||
use log::{error, info, trace};
|
||||
|
||||
use crate::accept::AcceptNotify;
|
||||
use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage};
|
||||
use crate::service::{BoxedServerService, InternalServiceFactory};
|
||||
use crate::socket::{SocketAddr, StdStream};
|
||||
use crate::Token;
|
||||
|
||||
|
@ -228,23 +228,12 @@ impl Worker {
|
|||
self.services.iter_mut().for_each(|srv| {
|
||||
if srv.status == WorkerServiceStatus::Available {
|
||||
srv.status = WorkerServiceStatus::Stopped;
|
||||
actix_rt::spawn(
|
||||
srv.service
|
||||
.call((None, ServerMessage::ForceShutdown))
|
||||
.map(|_| ()),
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let timeout = self.shutdown_timeout;
|
||||
self.services.iter_mut().for_each(move |srv| {
|
||||
if srv.status == WorkerServiceStatus::Available {
|
||||
srv.status = WorkerServiceStatus::Stopping;
|
||||
actix_rt::spawn(
|
||||
srv.service
|
||||
.call((None, ServerMessage::Shutdown(timeout)))
|
||||
.map(|_| ()),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -361,7 +350,7 @@ impl Future for Worker {
|
|||
let guard = self.conns.get();
|
||||
let _ = self.services[conn.token.0]
|
||||
.service
|
||||
.call((Some(guard), ServerMessage::Connect(conn.io)));
|
||||
.call((Some(guard), conn.io));
|
||||
} else {
|
||||
self.state = WorkerState::Available;
|
||||
self.availability.set(true);
|
||||
|
@ -455,7 +444,7 @@ impl Future for Worker {
|
|||
let guard = self.conns.get();
|
||||
let _ = self.services[msg.token.0]
|
||||
.service
|
||||
.call((Some(guard), ServerMessage::Connect(msg.io)));
|
||||
.call((Some(guard), msg.io));
|
||||
continue;
|
||||
}
|
||||
Ok(false) => {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
//! See [`Service`](trait.Service.html) docs for information on this crate's foundational trait.
|
||||
|
||||
#![deny(rust_2018_idioms, warnings)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::future::Future;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
//! Various helpers for Actix applications to use during testing.
|
||||
#![deny(rust_2018_idioms, warnings)]
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![allow(clippy::type_complexity, clippy::needless_doctest_main)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::sync::mpsc;
|
||||
use std::{net, thread};
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
//! Thread pool for blocking operations
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::fmt;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
//! * `rustls` - TLS acceptor using the `rustls` crate.
|
||||
//! * `nativetls` - TLS acceptor using the `native-tls` crate.
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
//! Actix tracing - support for tokio tracing with Actix services.
|
||||
#![deny(rust_2018_idioms, warnings)]
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::task::{Context, Poll};
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
//! Actix utils - various helper services
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
pub mod condition;
|
||||
pub mod counter;
|
||||
|
|
|
@ -42,7 +42,7 @@ macro_rules! parse_single_value {
|
|||
};
|
||||
}
|
||||
|
||||
pub struct PathDeserializer<'de, T: ResourcePath + 'de> {
|
||||
pub struct PathDeserializer<'de, T: ResourcePath> {
|
||||
path: &'de Path<T>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
//! Resource path matching library.
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
mod de;
|
||||
mod path;
|
||||
mod resource;
|
||||
|
|
|
@ -158,7 +158,7 @@ impl<T: ResourcePath> Path<T> {
|
|||
}
|
||||
|
||||
/// Return iterator to items in parameter container
|
||||
pub fn iter(&self) -> PathIter<T> {
|
||||
pub fn iter(&self) -> PathIter<'_, T> {
|
||||
PathIter {
|
||||
idx: 0,
|
||||
params: self,
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
//! A UTF-8 encoded read-only string using Bytes as storage.
|
||||
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::{borrow, fmt, hash, ops, str};
|
||||
|
||||
|
@ -156,13 +160,13 @@ macro_rules! array_impls {
|
|||
array_impls!(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16);
|
||||
|
||||
impl fmt::Debug for ByteString {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
(**self).fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ByteString {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
(**self).fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue