mirror of https://github.com/fafhrd91/actix-net
Compare commits
8 Commits
d61b33928d
...
064da0e3ff
Author | SHA1 | Date |
---|---|---|
|
064da0e3ff | |
|
270360e095 | |
|
d9203797be | |
|
67616902cc | |
|
809071b857 | |
|
8e7de17221 | |
|
2972a5ac08 | |
|
69041c4f6c |
|
@ -0,0 +1,8 @@
|
|||
version: "0.2"
|
||||
words:
|
||||
- actix
|
||||
- addrs
|
||||
- mptcp
|
||||
- nonblocking
|
||||
- oneshot
|
||||
- rustup
|
|
@ -8,3 +8,4 @@ updates:
|
|||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
versioning-strategy: lockfile-only
|
||||
|
|
|
@ -59,12 +59,12 @@ jobs:
|
|||
echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Rust (${{ matrix.version }})
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}
|
||||
|
||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||
uses: taiki-e/install-action@v2.49.45
|
||||
uses: taiki-e/install-action@v2.50.10
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
@ -116,12 +116,12 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust (nightly)
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
toolchain: nightly
|
||||
|
||||
- name: Install cargo-hack & cargo-minimal-versions
|
||||
uses: taiki-e/install-action@v2.49.45
|
||||
uses: taiki-e/install-action@v2.50.10
|
||||
with:
|
||||
tool: cargo-hack,cargo-minimal-versions
|
||||
|
||||
|
|
|
@ -68,12 +68,12 @@ jobs:
|
|||
echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Rust (${{ matrix.version.name }})
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
toolchain: ${{ matrix.version.version }}
|
||||
|
||||
- name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean
|
||||
uses: taiki-e/install-action@v2.49.45
|
||||
uses: taiki-e/install-action@v2.50.10
|
||||
with:
|
||||
tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean
|
||||
|
||||
|
@ -120,12 +120,12 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust (nightly)
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
toolchain: nightly
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@v2.49.45
|
||||
uses: taiki-e/install-action@v2.50.10
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
components: llvm-tools-preview
|
||||
|
||||
- name: Install cargo-llvm-cov
|
||||
uses: taiki-e/install-action@v2.49.45
|
||||
uses: taiki-e/install-action@v2.50.10
|
||||
with:
|
||||
tool: cargo-llvm-cov
|
||||
|
||||
|
@ -31,7 +31,7 @@ jobs:
|
|||
run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v5.4.0
|
||||
uses: codecov/codecov-action@v5.4.2
|
||||
with:
|
||||
files: codecov.json
|
||||
fail_ci_if_error: true
|
||||
|
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rustfmt
|
||||
|
@ -35,7 +35,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with: { components: clippy }
|
||||
|
||||
- uses: giraffate/clippy-action@v1.0.1
|
||||
|
@ -51,12 +51,12 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust (${{ vars.RUST_VERSION_EXTERNAL_TYPES }})
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.11.0
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1.12.0
|
||||
with:
|
||||
toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }}
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@v2.49.45
|
||||
uses: taiki-e/install-action@v2.50.10
|
||||
with:
|
||||
tool: just
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -187,10 +187,7 @@ impl SystemRunner {
|
|||
|
||||
match exit_code {
|
||||
0 => Ok(()),
|
||||
nonzero => Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Non-zero exit code: {}", nonzero),
|
||||
)),
|
||||
nonzero => Err(io::Error::other(format!("Non-zero exit code: {}", nonzero))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,8 +196,7 @@ impl SystemRunner {
|
|||
let SystemRunner { rt, stop_rx, .. } = self;
|
||||
|
||||
// run loop
|
||||
rt.block_on(stop_rx)
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
|
||||
rt.block_on(stop_rx).map_err(io::Error::other)
|
||||
}
|
||||
|
||||
/// Retrieves a reference to the underlying [Actix runtime](crate::Runtime) associated with this
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
## 2.6.0
|
||||
|
||||
- Add `ServerBuilder::shutdown_signal()` method.
|
||||
- Minimum supported Rust version (MSRV) is now 1.74.
|
||||
|
||||
## 2.5.1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "actix-server"
|
||||
version = "2.5.1"
|
||||
version = "2.6.0"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
|
@ -44,7 +44,10 @@ actix-rt = "2.8"
|
|||
bytes = "1"
|
||||
futures-util = { version = "0.3.17", default-features = false, features = ["sink", "async-await-macro"] }
|
||||
pretty_env_logger = "0.5"
|
||||
tokio = { version = "1.44.2", features = ["io-util", "rt-multi-thread", "macros", "fs"] }
|
||||
static_assertions = "1"
|
||||
tokio = { version = "1.44.2", features = ["io-util", "rt-multi-thread", "macros", "fs", "time"] }
|
||||
tokio-util = "0.7"
|
||||
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
<!-- prettier-ignore-start -->
|
||||
|
||||
[](https://crates.io/crates/actix-server)
|
||||
[](https://docs.rs/actix-server/2.5.1)
|
||||
[](https://docs.rs/actix-server/2.6.0)
|
||||
[](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html)
|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-server/2.5.1)
|
||||
[](https://deps.rs/crate/actix-server/2.6.0)
|
||||

|
||||
[](https://discord.gg/NWpN5mmg3x)
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
//! Demonstrates use of the `ServerBuilder::shutdown_signal` method using `tokio-util`s
|
||||
//! `CancellationToken` helper using a nonsensical timer. In practice, this cancellation token would
|
||||
//! be wired throughout your application and typically triggered by OS signals elsewhere.
|
||||
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use actix_rt::net::TcpStream;
|
||||
use actix_server::Server;
|
||||
use actix_service::fn_service;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::{prelude::*, EnvFilter};
|
||||
|
||||
async fn run(stop_signal: CancellationToken) -> io::Result<()> {
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.with(
|
||||
EnvFilter::builder()
|
||||
.with_default_directive(LevelFilter::INFO.into())
|
||||
.from_env_lossy(),
|
||||
)
|
||||
.init();
|
||||
|
||||
let addr = ("127.0.0.1", 8080);
|
||||
tracing::info!("starting server on port: {}", &addr.0);
|
||||
|
||||
Server::build()
|
||||
.bind("shutdown-signal", addr, || {
|
||||
fn_service(|_stream: TcpStream| async { Ok::<_, io::Error>(()) })
|
||||
})?
|
||||
.shutdown_signal(stop_signal.cancelled_owned())
|
||||
.workers(2)
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
let stop_signal = CancellationToken::new();
|
||||
|
||||
tokio::spawn({
|
||||
let stop_signal = stop_signal.clone();
|
||||
async move {
|
||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||
stop_signal.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
run(stop_signal).await?;
|
||||
Ok(())
|
||||
}
|
|
@ -76,7 +76,7 @@ impl Accept {
|
|||
let accept_handle = thread::Builder::new()
|
||||
.name("actix-server acceptor".to_owned())
|
||||
.spawn(move || accept.poll_with(&mut sockets))
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
|
||||
.map_err(io::Error::other)?;
|
||||
|
||||
Ok((waker_queue, handles_server, accept_handle))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{io, num::NonZeroUsize, time::Duration};
|
||||
use std::{future::Future, io, num::NonZeroUsize, time::Duration};
|
||||
|
||||
use actix_rt::net::TcpStream;
|
||||
use futures_core::future::BoxFuture;
|
||||
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
|
||||
|
||||
use crate::{
|
||||
|
@ -39,6 +40,7 @@ pub struct ServerBuilder {
|
|||
pub(crate) mptcp: MpTcp,
|
||||
pub(crate) exit: bool,
|
||||
pub(crate) listen_os_signals: bool,
|
||||
pub(crate) shutdown_signal: Option<BoxFuture<'static, ()>>,
|
||||
pub(crate) cmd_tx: UnboundedSender<ServerCommand>,
|
||||
pub(crate) cmd_rx: UnboundedReceiver<ServerCommand>,
|
||||
pub(crate) worker_config: ServerWorkerConfig,
|
||||
|
@ -64,6 +66,7 @@ impl ServerBuilder {
|
|||
mptcp: MpTcp::Disabled,
|
||||
exit: false,
|
||||
listen_os_signals: true,
|
||||
shutdown_signal: None,
|
||||
cmd_tx,
|
||||
cmd_rx,
|
||||
worker_config: ServerWorkerConfig::default(),
|
||||
|
@ -170,6 +173,41 @@ impl ServerBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Specify shutdown signal from a future.
|
||||
///
|
||||
/// Using this method will prevent OS signal handlers being set up.
|
||||
///
|
||||
/// Typically, a `CancellationToken` will be used, but any future _can_ be.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::io;
|
||||
/// # use tokio::net::TcpStream;
|
||||
/// # use actix_server::Server;
|
||||
/// # async fn run() -> io::Result<()> {
|
||||
/// use actix_service::fn_service;
|
||||
/// use tokio_util::sync::CancellationToken;
|
||||
///
|
||||
/// let stop_signal = CancellationToken::new();
|
||||
///
|
||||
/// Server::build()
|
||||
/// .bind("shutdown-signal", "127.0.0.1:12345", || {
|
||||
/// fn_service(|_stream: TcpStream| async { Ok::<_, io::Error>(()) })
|
||||
/// })?
|
||||
/// .shutdown_signal(stop_signal.cancelled_owned())
|
||||
/// .run()
|
||||
/// .await
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn shutdown_signal<Fut>(mut self, shutdown_signal: Fut) -> Self
|
||||
where
|
||||
Fut: Future<Output = ()> + Send + 'static,
|
||||
{
|
||||
self.shutdown_signal = Some(Box::pin(shutdown_signal));
|
||||
self
|
||||
}
|
||||
|
||||
/// Timeout for graceful workers shutdown in seconds.
|
||||
///
|
||||
/// After receiving a stop signal, workers have this much time to finish serving requests.
|
||||
|
@ -370,9 +408,6 @@ pub(super) fn bind_addr<S: ToSocketAddrs>(
|
|||
} else if let Some(err) = opt_err.take() {
|
||||
Err(err)
|
||||
} else {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Can not bind to address.",
|
||||
))
|
||||
Err(io::Error::other("Can not bind to address."))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
builder::ServerBuilder,
|
||||
join_all::join_all,
|
||||
service::InternalServiceFactory,
|
||||
signals::{SignalKind, Signals},
|
||||
signals::{OsSignals, SignalKind, StopSignal},
|
||||
waker_queue::{WakerInterest, WakerQueue},
|
||||
worker::{ServerWorker, ServerWorkerConfig, WorkerHandleServer},
|
||||
ServerHandle,
|
||||
|
@ -210,7 +210,12 @@ impl ServerInner {
|
|||
let (waker_queue, worker_handles, accept_handle) = Accept::start(sockets, &builder)?;
|
||||
|
||||
let mux = ServerEventMultiplexer {
|
||||
signal_fut: (builder.listen_os_signals).then(Signals::new),
|
||||
signal_fut: builder.shutdown_signal.map(StopSignal::Cancel).or_else(|| {
|
||||
builder
|
||||
.listen_os_signals
|
||||
.then(OsSignals::new)
|
||||
.map(StopSignal::Os)
|
||||
}),
|
||||
cmd_rx: builder.cmd_rx,
|
||||
};
|
||||
|
||||
|
@ -315,7 +320,16 @@ impl ServerInner {
|
|||
|
||||
fn map_signal(signal: SignalKind) -> ServerCommand {
|
||||
match signal {
|
||||
SignalKind::Int => {
|
||||
SignalKind::Cancel => {
|
||||
info!("Cancellation token/channel received; starting graceful shutdown");
|
||||
ServerCommand::Stop {
|
||||
graceful: true,
|
||||
completion: None,
|
||||
force_system_stop: true,
|
||||
}
|
||||
}
|
||||
|
||||
SignalKind::OsInt => {
|
||||
info!("SIGINT received; starting forced shutdown");
|
||||
ServerCommand::Stop {
|
||||
graceful: false,
|
||||
|
@ -324,7 +338,7 @@ impl ServerInner {
|
|||
}
|
||||
}
|
||||
|
||||
SignalKind::Term => {
|
||||
SignalKind::OsTerm => {
|
||||
info!("SIGTERM received; starting graceful shutdown");
|
||||
ServerCommand::Stop {
|
||||
graceful: true,
|
||||
|
@ -333,7 +347,7 @@ impl ServerInner {
|
|||
}
|
||||
}
|
||||
|
||||
SignalKind::Quit => {
|
||||
SignalKind::OsQuit => {
|
||||
info!("SIGQUIT received; starting forced shutdown");
|
||||
ServerCommand::Stop {
|
||||
graceful: false,
|
||||
|
@ -347,7 +361,7 @@ impl ServerInner {
|
|||
|
||||
struct ServerEventMultiplexer {
|
||||
cmd_rx: UnboundedReceiver<ServerCommand>,
|
||||
signal_fut: Option<Signals>,
|
||||
signal_fut: Option<StopSignal>,
|
||||
}
|
||||
|
||||
impl Stream for ServerEventMultiplexer {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use std::{
|
||||
fmt,
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
pin::{pin, Pin},
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use futures_core::future::BoxFuture;
|
||||
use tracing::trace;
|
||||
|
||||
/// Types of process signals.
|
||||
|
@ -12,28 +13,51 @@ use tracing::trace;
|
|||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[allow(dead_code)] // variants are never constructed on non-unix
|
||||
pub(crate) enum SignalKind {
|
||||
/// `SIGINT`
|
||||
Int,
|
||||
/// Cancellation token or channel.
|
||||
Cancel,
|
||||
|
||||
/// `SIGTERM`
|
||||
Term,
|
||||
/// OS `SIGINT`.
|
||||
OsInt,
|
||||
|
||||
/// `SIGQUIT`
|
||||
Quit,
|
||||
/// OS `SIGTERM`.
|
||||
OsTerm,
|
||||
|
||||
/// OS `SIGQUIT`.
|
||||
OsQuit,
|
||||
}
|
||||
|
||||
impl fmt::Display for SignalKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(match self {
|
||||
SignalKind::Int => "SIGINT",
|
||||
SignalKind::Term => "SIGTERM",
|
||||
SignalKind::Quit => "SIGQUIT",
|
||||
SignalKind::Cancel => "Cancellation token or channel",
|
||||
SignalKind::OsInt => "SIGINT",
|
||||
SignalKind::OsTerm => "SIGTERM",
|
||||
SignalKind::OsQuit => "SIGQUIT",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum StopSignal {
|
||||
/// OS signal handling is configured.
|
||||
Os(OsSignals),
|
||||
|
||||
/// Cancellation token or channel.
|
||||
Cancel(BoxFuture<'static, ()>),
|
||||
}
|
||||
|
||||
impl Future for StopSignal {
|
||||
type Output = SignalKind;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match self.get_mut() {
|
||||
StopSignal::Os(os_signals) => pin!(os_signals).poll(cx),
|
||||
StopSignal::Cancel(cancel) => pin!(cancel).poll(cx).map(|()| SignalKind::Cancel),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Process signal listener.
|
||||
pub(crate) struct Signals {
|
||||
pub(crate) struct OsSignals {
|
||||
#[cfg(not(unix))]
|
||||
signals: futures_core::future::BoxFuture<'static, std::io::Result<()>>,
|
||||
|
||||
|
@ -41,14 +65,14 @@ pub(crate) struct Signals {
|
|||
signals: Vec<(SignalKind, actix_rt::signal::unix::Signal)>,
|
||||
}
|
||||
|
||||
impl Signals {
|
||||
impl OsSignals {
|
||||
/// Constructs an OS signal listening future.
|
||||
pub(crate) fn new() -> Self {
|
||||
trace!("setting up OS signal listener");
|
||||
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
Signals {
|
||||
OsSignals {
|
||||
signals: Box::pin(actix_rt::signal::ctrl_c()),
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +82,9 @@ impl Signals {
|
|||
use actix_rt::signal::unix;
|
||||
|
||||
let sig_map = [
|
||||
(unix::SignalKind::interrupt(), SignalKind::Int),
|
||||
(unix::SignalKind::terminate(), SignalKind::Term),
|
||||
(unix::SignalKind::quit(), SignalKind::Quit),
|
||||
(unix::SignalKind::interrupt(), SignalKind::OsInt),
|
||||
(unix::SignalKind::terminate(), SignalKind::OsTerm),
|
||||
(unix::SignalKind::quit(), SignalKind::OsQuit),
|
||||
];
|
||||
|
||||
let signals = sig_map
|
||||
|
@ -79,18 +103,18 @@ impl Signals {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Signals { signals }
|
||||
OsSignals { signals }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Future for Signals {
|
||||
impl Future for OsSignals {
|
||||
type Output = SignalKind;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
self.signals.as_mut().poll(cx).map(|_| SignalKind::Int)
|
||||
self.signals.as_mut().poll(cx).map(|_| SignalKind::OsInt)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -106,3 +130,10 @@ impl Future for Signals {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
static_assertions::assert_impl_all!(StopSignal: Send, Unpin);
|
||||
}
|
||||
|
|
|
@ -341,11 +341,10 @@ impl ServerWorker {
|
|||
Ok((token, svc)) => services.push((idx, token, svc)),
|
||||
|
||||
Err(err) => {
|
||||
error!("can not start worker: {:?}", err);
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("can not start server service {}", idx),
|
||||
));
|
||||
error!("can not start worker: {err:?}");
|
||||
return Err(io::Error::other(format!(
|
||||
"can not start server service {idx}",
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -440,13 +439,12 @@ impl ServerWorker {
|
|||
Ok((token, svc)) => services.push((idx, token, svc)),
|
||||
|
||||
Err(err) => {
|
||||
error!("can not start worker: {:?}", err);
|
||||
error!("can not start worker: {err:?}");
|
||||
Arbiter::current().stop();
|
||||
factory_tx
|
||||
.send(Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("can not start server service {}", idx),
|
||||
)))
|
||||
.send(Err(io::Error::other(format!(
|
||||
"can not start server service {idx}",
|
||||
))))
|
||||
.unwrap();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! When MSRV is 1.48, replace with `core::future::Ready` and `core::future::ready()`.
|
||||
//! When MSRV is 1.82, replace with `core::future::Ready` and `core::future::ready()`.
|
||||
|
||||
use core::{
|
||||
future::Future,
|
||||
|
|
36
justfile
36
justfile
|
@ -1,6 +1,8 @@
|
|||
_list:
|
||||
@just --list
|
||||
|
||||
toolchain := ""
|
||||
|
||||
# Check project.
|
||||
check: && clippy
|
||||
just --unstable --fmt --check
|
||||
|
@ -21,11 +23,11 @@ fmt:
|
|||
# Downgrade dependencies necessary to run MSRV checks/tests.
|
||||
[private]
|
||||
downgrade-for-msrv:
|
||||
cargo update -p=clap --precise=4.4.18 # next ver: 1.74.0
|
||||
cargo update -p=native-tls --precise=0.2.13 # next ver: 1.80.0
|
||||
cargo update -p=litemap --precise=0.7.4 # next ver: 1.81.0
|
||||
cargo update -p=zerofrom --precise=0.1.5 # next ver: 1.81.0
|
||||
cargo update -p=half --precise=2.4.1 # next ver: 1.81.0
|
||||
cargo {{ toolchain }} update -p=native-tls --precise=0.2.13 # next ver: 1.80.0
|
||||
cargo {{ toolchain }} update -p=idna_adapter --precise=1.2.0 # next ver: 1.82.0
|
||||
cargo {{ toolchain }} update -p=litemap --precise=0.7.4 # next ver: 1.81.0
|
||||
cargo {{ toolchain }} update -p=zerofrom --precise=0.1.5 # next ver: 1.81.0
|
||||
cargo {{ toolchain }} update -p=half --precise=2.4.1 # next ver: 1.81.0
|
||||
|
||||
msrv := ```
|
||||
cargo metadata --format-version=1 \
|
||||
|
@ -43,37 +45,39 @@ non_linux_all_features_list := ```
|
|||
all_crate_features := if os() == "linux" { "--all-features" } else { "--features='" + non_linux_all_features_list + "'" }
|
||||
|
||||
# Run Clippy over workspace.
|
||||
clippy toolchain="":
|
||||
clippy:
|
||||
cargo {{ toolchain }} clippy --workspace --all-targets {{ all_crate_features }}
|
||||
|
||||
# Run Clippy using MSRV.
|
||||
clippy-msrv: downgrade-for-msrv (clippy msrv_rustup)
|
||||
clippy-msrv: downgrade-for-msrv
|
||||
@just toolchain={{ msrv_rustup }} clippy
|
||||
|
||||
# Test workspace code.
|
||||
[macos]
|
||||
[windows]
|
||||
test toolchain="":
|
||||
test:
|
||||
cargo {{ toolchain }} test --lib --tests --package=actix-macros
|
||||
cargo {{ toolchain }} nextest run --no-tests=warn --workspace --exclude=actix-macros --no-default-features
|
||||
cargo {{ toolchain }} nextest run --no-tests=warn --workspace --exclude=actix-macros {{ all_crate_features }}
|
||||
|
||||
# Test workspace code.
|
||||
[linux]
|
||||
test toolchain="":
|
||||
test:
|
||||
cargo {{ toolchain }} test --lib --tests --package=actix-macros
|
||||
cargo {{ toolchain }} nextest run --no-tests=warn --workspace --exclude=actix-macros --no-default-features
|
||||
cargo {{ toolchain }} nextest run --no-tests=warn --workspace --exclude=actix-macros {{ non_linux_all_features_list }}
|
||||
cargo {{ toolchain }} nextest run --no-tests=warn --workspace --exclude=actix-macros {{ all_crate_features }}
|
||||
|
||||
# Test workspace using MSRV.
|
||||
test-msrv: downgrade-for-msrv (test msrv_rustup)
|
||||
test-msrv: downgrade-for-msrv
|
||||
@just toolchain={{ msrv_rustup }} test
|
||||
|
||||
# Test workspace docs.
|
||||
test-docs toolchain="": && doc
|
||||
test-docs: && doc
|
||||
cargo {{ toolchain }} test --doc --workspace {{ all_crate_features }} --no-fail-fast -- --nocapture
|
||||
|
||||
# Test workspace.
|
||||
test-all toolchain="": (test toolchain) (test-docs toolchain)
|
||||
test-all: test test-docs
|
||||
|
||||
# Document crates in workspace.
|
||||
doc *args: && doc-set-workspace-crates
|
||||
|
@ -96,12 +100,12 @@ doc-watch:
|
|||
cargo watch -- just doc
|
||||
|
||||
# Check for unintentional external type exposure on all crates in workspace.
|
||||
check-external-types-all toolchain="+nightly":
|
||||
check-external-types-all:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
exit=0
|
||||
for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml | grep -vE "\-codegen/|\-derive/|\-macros/"); do
|
||||
if ! just check-external-types-manifest "$f" {{ toolchain }}; then exit=1; fi
|
||||
if ! just toolchain="+nightly" check-external-types-manifest "$f"; then exit=1; fi
|
||||
echo
|
||||
echo
|
||||
done
|
||||
|
@ -114,9 +118,9 @@ check-external-types-all-table toolchain="+nightly":
|
|||
for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml | grep -vE "\-codegen/|\-derive/|\-macros/"); do
|
||||
echo
|
||||
echo "Checking for $f"
|
||||
just check-external-types-manifest "$f" {{ toolchain }} --output-format=markdown-table
|
||||
just toolchain="+nightly" check-external-types-manifest "$f" --output-format=markdown-table
|
||||
done
|
||||
|
||||
# Check for unintentional external type exposure on a crate.
|
||||
check-external-types-manifest manifest_path toolchain="+nightly" *extra_args="":
|
||||
check-external-types-manifest manifest_path *extra_args="":
|
||||
cargo {{ toolchain }} check-external-types --manifest-path "{{ manifest_path }}" {{ extra_args }}
|
||||
|
|
Loading…
Reference in New Issue