mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-25 02:51:12 +00:00
Remove futures-util dependency
This commit is contained in:
parent
6714fe48ed
commit
206db2079f
8 changed files with 36 additions and 22 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -401,7 +401,6 @@ dependencies = [
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"flume",
|
"flume",
|
||||||
"futures-util",
|
|
||||||
"http-signature-normalization-actix",
|
"http-signature-normalization-actix",
|
||||||
"http-signature-normalization-reqwest",
|
"http-signature-normalization-reqwest",
|
||||||
"lru",
|
"lru",
|
||||||
|
@ -427,6 +426,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sled",
|
"sled",
|
||||||
|
"streem",
|
||||||
"teloxide",
|
"teloxide",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time",
|
"time",
|
||||||
|
@ -3064,6 +3064,16 @@ dependencies = [
|
||||||
"der",
|
"der",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "streem"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "56bcbf3c75c402c87b9a1947202c83bbc566ba9f4b788ee3d39db75f20c840a2"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "string_cache"
|
name = "string_cache"
|
||||||
version = "0.8.7"
|
version = "0.8.7"
|
||||||
|
|
|
@ -36,7 +36,6 @@ console-subscriber = { version = "0.1", optional = true }
|
||||||
dashmap = "5.1.0"
|
dashmap = "5.1.0"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
flume = "0.11.0"
|
flume = "0.11.0"
|
||||||
futures-util = "0.3.17"
|
|
||||||
lru = "0.11.0"
|
lru = "0.11.0"
|
||||||
metrics = "0.21.0"
|
metrics = "0.21.0"
|
||||||
metrics-exporter-prometheus = { version = "0.12.0", default-features = false, features = [
|
metrics-exporter-prometheus = { version = "0.12.0", default-features = false, features = [
|
||||||
|
@ -80,6 +79,7 @@ tracing-subscriber = { version = "0.3", features = [
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1", features = ["macros", "sync"] }
|
tokio = { version = "1", features = ["macros", "sync"] }
|
||||||
uuid = { version = "1", features = ["v4", "serde"] }
|
uuid = { version = "1", features = ["v4", "serde"] }
|
||||||
|
streem = "0.1.0"
|
||||||
|
|
||||||
[dependencies.background-jobs]
|
[dependencies.background-jobs]
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
|
|
|
@ -9,12 +9,11 @@ use actix_web::{
|
||||||
FromRequest, HttpMessage, HttpRequest, HttpResponse, ResponseError,
|
FromRequest, HttpMessage, HttpRequest, HttpResponse, ResponseError,
|
||||||
};
|
};
|
||||||
use bcrypt::{BcryptError, DEFAULT_COST};
|
use bcrypt::{BcryptError, DEFAULT_COST};
|
||||||
use futures_util::future::LocalBoxFuture;
|
|
||||||
use http_signature_normalization_actix::{prelude::InvalidHeaderValue, Canceled, Spawn};
|
use http_signature_normalization_actix::{prelude::InvalidHeaderValue, Canceled, Spawn};
|
||||||
use std::{convert::Infallible, str::FromStr, time::Instant};
|
use std::{convert::Infallible, str::FromStr, time::Instant};
|
||||||
use tracing_error::SpanTrace;
|
use tracing_error::SpanTrace;
|
||||||
|
|
||||||
use crate::{db::Db, spawner::Spawner};
|
use crate::{db::Db, future::LocalBoxFuture, spawner::Spawner};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AdminConfig {
|
pub(crate) struct AdminConfig {
|
||||||
|
|
3
src/future.rs
Normal file
3
src/future.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
use std::{future::Future, pin::Pin};
|
||||||
|
|
||||||
|
pub(crate) type LocalBoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>;
|
|
@ -1,10 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Error,
|
error::Error,
|
||||||
|
future::LocalBoxFuture,
|
||||||
jobs::{debug_object, Deliver, JobState},
|
jobs::{debug_object, Deliver, JobState},
|
||||||
};
|
};
|
||||||
use activitystreams::iri_string::types::IriString;
|
use activitystreams::iri_string::types::IriString;
|
||||||
use background_jobs::ActixJob;
|
use background_jobs::ActixJob;
|
||||||
use futures_util::future::LocalBoxFuture;
|
|
||||||
|
|
||||||
#[derive(Clone, serde::Deserialize, serde::Serialize)]
|
#[derive(Clone, serde::Deserialize, serde::Serialize)]
|
||||||
pub(crate) struct DeliverMany {
|
pub(crate) struct DeliverMany {
|
||||||
|
|
|
@ -31,6 +31,7 @@ mod data;
|
||||||
mod db;
|
mod db;
|
||||||
mod error;
|
mod error;
|
||||||
mod extractors;
|
mod extractors;
|
||||||
|
mod future;
|
||||||
mod jobs;
|
mod jobs;
|
||||||
mod middleware;
|
mod middleware;
|
||||||
mod requests;
|
mod requests;
|
||||||
|
|
|
@ -4,14 +4,11 @@ use actix_web::{
|
||||||
web::BytesMut,
|
web::BytesMut,
|
||||||
HttpMessage,
|
HttpMessage,
|
||||||
};
|
};
|
||||||
use futures_util::{
|
|
||||||
future::TryFutureExt,
|
|
||||||
stream::{once, TryStreamExt},
|
|
||||||
};
|
|
||||||
use std::{
|
use std::{
|
||||||
future::{ready, Ready},
|
future::{ready, Ready},
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
use streem::IntoStreamer;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct DebugPayload(pub bool);
|
pub(crate) struct DebugPayload(pub bool);
|
||||||
|
@ -53,19 +50,23 @@ where
|
||||||
|
|
||||||
fn call(&self, mut req: ServiceRequest) -> Self::Future {
|
fn call(&self, mut req: ServiceRequest) -> Self::Future {
|
||||||
if self.0 && req.method() == Method::POST {
|
if self.0 && req.method() == Method::POST {
|
||||||
let pl = req.take_payload();
|
let mut pl = req.take_payload().into_streamer();
|
||||||
|
|
||||||
req.set_payload(Payload::Stream {
|
req.set_payload(Payload::Stream {
|
||||||
payload: Box::pin(once(
|
payload: Box::pin(streem::try_from_fn(|yielder| async move {
|
||||||
pl.try_fold(BytesMut::new(), |mut acc, bytes| async {
|
let mut buf = BytesMut::new();
|
||||||
acc.extend(bytes);
|
|
||||||
Ok(acc)
|
while let Some(bytes) = pl.try_next().await? {
|
||||||
})
|
buf.extend(bytes);
|
||||||
.map_ok(|bytes| {
|
}
|
||||||
let bytes = bytes.freeze();
|
|
||||||
tracing::info!("{}", String::from_utf8_lossy(&bytes));
|
let bytes = buf.freeze();
|
||||||
bytes
|
tracing::info!("{}", String::from_utf8_lossy(&bytes));
|
||||||
}),
|
|
||||||
)),
|
yielder.yield_ok(bytes).await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})),
|
||||||
});
|
});
|
||||||
|
|
||||||
self.1.call(req)
|
self.1.call(req)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, UrlKind},
|
config::{Config, UrlKind},
|
||||||
data::State,
|
data::State,
|
||||||
|
future::LocalBoxFuture,
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_webfinger::{Resolver, Webfinger};
|
use actix_webfinger::{Resolver, Webfinger};
|
||||||
use futures_util::future::LocalBoxFuture;
|
|
||||||
use rsa_magic_public_key::AsMagicPublicKey;
|
use rsa_magic_public_key::AsMagicPublicKey;
|
||||||
|
|
||||||
pub(crate) struct RelayResolver;
|
pub(crate) struct RelayResolver;
|
||||||
|
|
Loading…
Reference in a new issue