Generic error for body stream

This commit is contained in:
Dominik Werder
2024-11-04 11:05:01 +01:00
parent 3b31c244ee
commit 66538ced79
6 changed files with 27 additions and 16 deletions

View File

@@ -91,7 +91,6 @@ impl FindActiveHandler {
.map_or(accept_def, |k| k.to_str().unwrap_or(accept_def));
let _url = req_uri_to_url(req.uri()).map_err(|_| FindActiveError::HttpBadUrl)?;
if accept.contains(APP_JSON) || accept.contains(ACCEPT_ALL) {
type _A = netpod::BodyStream;
let stream = FindActiveStream::new(40, 2, ncc);
let stream = stream.chain(FindActiveStream::new(40, 3, ncc));
let stream = stream.chain(FindActiveStream::new(40, 4, ncc));

View File

@@ -11,7 +11,6 @@ doctest = false
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_cbor = "0.11.2"
ciborium = "0.2.1"
rmp-serde = "1.1.1"
postcard = { version = "1.0.0", features = ["use-std"] }
@@ -22,8 +21,8 @@ num-traits = "0.2.15"
chrono = { version = "0.4.19", features = ["serde"] }
crc32fast = "1.3.2"
futures-util = "0.3.24"
tokio = { version = "1.20", features = ["rt-multi-thread", "sync", "time"] }
humantime-serde = "1.1.1"
thiserror = "1"
err = { path = "../err" }
items_0 = { path = "../items_0" }
items_proc = { path = "../items_proc" }
@@ -31,3 +30,9 @@ netpod = { path = "../netpod" }
taskrun = { path = "../taskrun" }
parse = { path = "../parse" }
bitshuffle = { path = "../bitshuffle" }
[patch.crates-io]
thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" }
[features]
heavy = []

View File

@@ -14,6 +14,7 @@ pub mod frame;
pub mod inmem;
pub mod merger;
pub mod streams;
#[cfg(feature = "heavy")]
#[cfg(test)]
pub mod test;
pub mod testgen;
@@ -174,12 +175,3 @@ impl Mergeable for Box<dyn Events> {
pub trait ChannelEventsInput: Stream<Item = Sitemty<ChannelEvents>> + EventTransform + Send {}
impl<T> ChannelEventsInput for T where T: Stream<Item = Sitemty<ChannelEvents>> + EventTransform + Send {}
pub fn runfut<T, F>(fut: F) -> Result<T, err::Error>
where
F: std::future::Future<Output = Result<T, Error>>,
{
use futures_util::TryFutureExt;
let fut = fut.map_err(|e| e.into());
taskrun::run(fut)
}

View File

@@ -31,6 +31,16 @@ use netpod::BinnedRangeEnum;
use std::time::Duration;
use std::time::Instant;
#[cfg(test)]
pub fn runfut<T, F>(fut: F) -> Result<T, err::Error>
where
F: std::future::Future<Output = Result<T, Error>>,
{
use futures_util::TryFutureExt;
let fut = fut.map_err(|e| e.into());
taskrun::run(fut)
}
#[test]
fn items_move_events() {
let evs = make_some_boxed_d0_f32(10, SEC, SEC, 0, 1846713782);

View File

@@ -13,7 +13,6 @@ serde_json = "1.0"
http = "1.0.0"
humantime = "2.1.0"
humantime-serde = "1.1.1"
async-channel = "1.8.0"
bytes = "1.4.0"
chrono = { version = "0.4.19", features = ["serde"] }
futures-util = "0.3.14"
@@ -22,4 +21,8 @@ url = "2.5.0"
num-traits = "0.2.16"
hex = "0.4.3"
rand = "0.8.5"
thiserror = "1"
err = { path = "../err" }
[patch.crates-io]
thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" }

View File

@@ -188,9 +188,11 @@ pub enum AsyncChannelError {
Recv,
}
pub struct BodyStream {
//pub receiver: async_channel::Receiver<Result<Bytes, Error>>,
pub inner: Box<dyn Stream<Item = Result<Bytes, Error>> + Send + Unpin>,
pub struct BodyStream<E>
where
E: std::error::Error,
{
pub inner: Box<dyn Stream<Item = Result<Bytes, E>> + Send + Unpin>,
}
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize)]