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