mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +00:00
Remove direct dependency on actix-rt and actix-server
This commit is contained in:
parent
0926739d3c
commit
745e990fa0
17 changed files with 44 additions and 34 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -175,11 +175,13 @@ checksum = "0e4a5b5e29603ca8c94a77c65cf874718ceb60292c5a5c3e5f4ace041af462b9"
|
|||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-http",
|
||||
"actix-macros",
|
||||
"actix-router",
|
||||
"actix-rt",
|
||||
"actix-server",
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"actix-web-codegen",
|
||||
"ahash 0.8.3",
|
||||
"bytes",
|
||||
"bytestring",
|
||||
|
@ -204,6 +206,18 @@ dependencies = [
|
|||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-web-codegen"
|
||||
version = "4.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb1f50ebbb30eca122b188319a4398b3f7bb4a8cdf50ecfb73bfc6a3c3ce54f5"
|
||||
dependencies = [
|
||||
"actix-router",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.31",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.21.0"
|
||||
|
@ -1804,8 +1818,6 @@ name = "pict-rs"
|
|||
version = "0.5.0-alpha.17"
|
||||
dependencies = [
|
||||
"actix-form-data",
|
||||
"actix-rt",
|
||||
"actix-server",
|
||||
"actix-web",
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
|
|
|
@ -11,13 +11,11 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
default = []
|
||||
io-uring = ["actix-rt/io-uring", "actix-server/io-uring", "tokio-uring", "sled/io_uring"]
|
||||
io-uring = ["dep:tokio-uring", "sled/io_uring", "actix-web/experimental-io-uring"]
|
||||
|
||||
[dependencies]
|
||||
actix-form-data = "0.7.0-beta.4"
|
||||
actix-rt = { version = "2.7.0", default-features = false }
|
||||
actix-server = "2.0.0"
|
||||
actix-web = { version = "4.0.0", default-features = false }
|
||||
actix-web = { version = "4.0.0", default-features = false, features = ["macros"] }
|
||||
anyhow = "1.0"
|
||||
async-trait = "0.1.51"
|
||||
barrel = { version = "0.7.0", features = ["pg"] }
|
||||
|
|
|
@ -380,8 +380,8 @@ mod io_uring {
|
|||
|
||||
macro_rules! test_on_arbiter {
|
||||
($fut:expr) => {
|
||||
actix_rt::System::new().block_on(async move {
|
||||
let arbiter = actix_rt::Arbiter::new();
|
||||
actix_web::rt::System::new().block_on(async move {
|
||||
let arbiter = actix_web::rt::Arbiter::new();
|
||||
|
||||
let (tx, rx) = crate::sync::channel(1);
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ use std::{
|
|||
pub(crate) type LocalBoxFuture<'a, T> = std::pin::Pin<Box<dyn Future<Output = T> + 'a>>;
|
||||
|
||||
pub(crate) trait WithTimeout: Future {
|
||||
fn with_timeout(self, duration: Duration) -> actix_rt::time::Timeout<Self>
|
||||
fn with_timeout(self, duration: Duration) -> actix_web::rt::time::Timeout<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
actix_rt::time::timeout(duration, self)
|
||||
actix_web::rt::time::timeout(duration, self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ mod test {
|
|||
|
||||
macro_rules! test_on_arbiter {
|
||||
($fut:expr) => {
|
||||
actix_rt::System::new().block_on(async move {
|
||||
let arbiter = actix_rt::Arbiter::new();
|
||||
actix_web::rt::System::new().block_on(async move {
|
||||
let arbiter = actix_web::rt::Arbiter::new();
|
||||
|
||||
let (tx, rx) = crate::sync::channel(1);
|
||||
|
||||
|
|
|
@ -1707,7 +1707,7 @@ fn spawn_cleanup(repo: ArcRepo, config: &Configuration) {
|
|||
}
|
||||
|
||||
crate::sync::spawn(async move {
|
||||
let mut interval = actix_rt::time::interval(Duration::from_secs(30));
|
||||
let mut interval = actix_web::rt::time::interval(Duration::from_secs(30));
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> color_eyre::Result<()> {
|
||||
pict_rs::PictRsConfiguration::build_default()?
|
||||
.install_tracing()?
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
mod metrics;
|
||||
|
||||
use actix_rt::time::Timeout;
|
||||
use actix_web::{
|
||||
dev::{Service, ServiceRequest, Transform},
|
||||
http::StatusCode,
|
||||
rt::time::Timeout,
|
||||
HttpResponse, ResponseError,
|
||||
};
|
||||
use std::{
|
||||
|
|
|
@ -62,7 +62,7 @@ where
|
|||
tracing::warn!("Retrying migration +{failure_count}");
|
||||
}
|
||||
|
||||
actix_rt::time::sleep(Duration::from_secs(3)).await;
|
||||
actix_web::rt::time::sleep(Duration::from_secs(3)).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -366,7 +366,7 @@ where
|
|||
tracing::warn!("Failed moving file. Retrying +{failure_count}");
|
||||
}
|
||||
|
||||
actix_rt::time::sleep(Duration::from_secs(3)).await;
|
||||
actix_web::rt::time::sleep(Duration::from_secs(3)).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use actix_rt::task::JoinHandle;
|
||||
use actix_web::rt::task::JoinHandle;
|
||||
use actix_web::web::Bytes;
|
||||
use flume::r#async::RecvFut;
|
||||
use std::{
|
||||
|
@ -78,7 +78,7 @@ pub(crate) struct ProcessRead<I> {
|
|||
#[allow(dead_code)]
|
||||
handle: DropHandle,
|
||||
eof: bool,
|
||||
sleep: Pin<Box<actix_rt::time::Sleep>>,
|
||||
sleep: Pin<Box<actix_web::rt::time::Sleep>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
@ -238,7 +238,7 @@ impl Process {
|
|||
.instrument(span),
|
||||
);
|
||||
|
||||
let sleep = actix_rt::time::sleep(timeout);
|
||||
let sleep = actix_web::rt::time::sleep(timeout);
|
||||
|
||||
ProcessRead {
|
||||
inner: stdout,
|
||||
|
|
|
@ -207,7 +207,7 @@ async fn process_jobs<S, F>(
|
|||
tracing::warn!("{}", format!("{e:?}"));
|
||||
|
||||
if e.is_disconnected() {
|
||||
actix_rt::time::sleep(Duration::from_secs(10)).await;
|
||||
actix_web::rt::time::sleep(Duration::from_secs(10)).await;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -341,7 +341,7 @@ async fn process_image_jobs<S, F>(
|
|||
tracing::warn!("{}", format!("{e:?}"));
|
||||
|
||||
if e.is_disconnected() {
|
||||
actix_rt::time::sleep(Duration::from_secs(3)).await;
|
||||
actix_web::rt::time::sleep(Duration::from_secs(3)).await;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -421,7 +421,7 @@ where
|
|||
let mut fut =
|
||||
std::pin::pin!(fut.instrument(tracing::info_span!("job-future", job_id = ?job_id)));
|
||||
|
||||
let mut interval = actix_rt::time::interval(Duration::from_secs(5));
|
||||
let mut interval = actix_web::rt::time::interval(Duration::from_secs(5));
|
||||
|
||||
let mut hb = None;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ use super::{
|
|||
pub(crate) struct PostgresRepo {
|
||||
inner: Arc<Inner>,
|
||||
#[allow(dead_code)]
|
||||
notifications: Arc<actix_rt::task::JoinHandle<()>>,
|
||||
notifications: Arc<actix_web::rt::task::JoinHandle<()>>,
|
||||
}
|
||||
|
||||
struct Inner {
|
||||
|
|
|
@ -1537,8 +1537,8 @@ impl std::fmt::Debug for SledRepo {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<actix_rt::task::JoinError> for SledError {
|
||||
fn from(_: actix_rt::task::JoinError) -> Self {
|
||||
impl From<actix_web::rt::task::JoinError> for SledError {
|
||||
fn from(_: actix_web::rt::task::JoinError) -> Self {
|
||||
SledError::Panic
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,8 +316,8 @@ impl std::fmt::Debug for SledRepo {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<actix_rt::task::JoinError> for SledError {
|
||||
fn from(_: actix_rt::task::JoinError) -> Self {
|
||||
impl From<actix_web::rt::task::JoinError> for SledError {
|
||||
fn from(_: actix_web::rt::task::JoinError) -> Self {
|
||||
SledError::Panic
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ use crate::{
|
|||
bytes_stream::BytesStream, error_code::ErrorCode, future::WithMetrics, repo::ArcRepo,
|
||||
store::Store, stream::LocalBoxStream,
|
||||
};
|
||||
use actix_rt::task::JoinError;
|
||||
use actix_web::{
|
||||
error::BlockingError,
|
||||
http::{
|
||||
header::{ByteRangeSpec, Range, CONTENT_LENGTH},
|
||||
StatusCode,
|
||||
},
|
||||
rt::task::JoinError,
|
||||
web::Bytes,
|
||||
};
|
||||
use base64::{prelude::BASE64_STANDARD, Engine};
|
||||
|
|
|
@ -148,7 +148,7 @@ where
|
|||
S::Item: 'static,
|
||||
{
|
||||
streem::try_from_fn(|yielder| async move {
|
||||
actix_rt::time::timeout(duration, async move {
|
||||
actix_web::rt::time::timeout(duration, async move {
|
||||
let stream = std::pin::pin!(stream);
|
||||
let mut streamer = stream.into_streamer();
|
||||
|
||||
|
|
|
@ -23,16 +23,16 @@ pub(crate) fn bare_semaphore(permits: usize) -> Semaphore {
|
|||
}
|
||||
|
||||
#[track_caller]
|
||||
pub(crate) fn spawn<F>(future: F) -> actix_rt::task::JoinHandle<F::Output>
|
||||
pub(crate) fn spawn<F>(future: F) -> actix_web::rt::task::JoinHandle<F::Output>
|
||||
where
|
||||
F: std::future::Future + 'static,
|
||||
F::Output: 'static,
|
||||
{
|
||||
tracing::trace_span!(parent: None, "spawn task").in_scope(|| actix_rt::spawn(future))
|
||||
tracing::trace_span!(parent: None, "spawn task").in_scope(|| actix_web::rt::spawn(future))
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub(crate) fn spawn_blocking<F, Out>(function: F) -> actix_rt::task::JoinHandle<Out>
|
||||
pub(crate) fn spawn_blocking<F, Out>(function: F) -> actix_web::rt::task::JoinHandle<Out>
|
||||
where
|
||||
F: FnOnce() -> Out + Send + 'static,
|
||||
Out: Send + 'static,
|
||||
|
@ -40,5 +40,5 @@ where
|
|||
let outer_span = tracing::Span::current();
|
||||
|
||||
tracing::trace_span!(parent: None, "spawn blocking task")
|
||||
.in_scope(|| actix_rt::task::spawn_blocking(move || outer_span.in_scope(function)))
|
||||
.in_scope(|| actix_web::rt::task::spawn_blocking(move || outer_span.in_scope(function)))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue