This commit is contained in:
Dominik Werder
2023-07-19 19:02:28 +02:00
parent 907eed350d
commit df091c0eb7
10 changed files with 188 additions and 77 deletions

View File

@@ -18,6 +18,7 @@ use tokio::io::AsyncReadExt;
use tokio::io::AsyncSeekExt;
use tokio::io::ErrorKind;
use tokio::io::SeekFrom;
use tracing::Instrument;
#[cfg(test)]
const BACKEND: &str = "testbackend-00";
@@ -212,28 +213,33 @@ impl fmt::Debug for OpenedFile {
pub fn open_files(
range: &NanoRange,
fetch_info: &SfChFetchInfo,
reqid: &str,
node: Node,
) -> async_channel::Receiver<Result<OpenedFileSet, Error>> {
let span = tracing::span!(tracing::Level::DEBUG, "open_files", reqid);
let (chtx, chrx) = async_channel::bounded(2);
let range = range.clone();
let fetch_info = fetch_info.clone();
tokio::spawn(async move {
match open_files_inner(&chtx, &range, &fetch_info, node).await {
Ok(_) => {}
Err(e) => {
let e = e.add_public_msg(format!(
"Can not open file for channel: {fetch_info:?} range: {range:?}"
));
match chtx.send(Err(e.into())).await {
Ok(_) => {}
Err(e) => {
// This case is fine.
debug!("open_files channel send error {:?}", e);
tokio::spawn(
async move {
match open_files_inner(&chtx, &range, &fetch_info, node).await {
Ok(_) => {}
Err(e) => {
let e = e.add_public_msg(format!(
"Can not open file for channel: {fetch_info:?} range: {range:?}"
));
match chtx.send(Err(e.into())).await {
Ok(_) => {}
Err(e) => {
// This case is fine.
debug!("open_files channel send error {:?}", e);
}
}
}
}
}
});
.instrument(span),
);
chrx
}

View File

@@ -72,7 +72,7 @@ impl EventChunkerMultifile {
let file_chan = if expand {
open_expanded_files(&range, &fetch_info, node)
} else {
open_files(&range, &fetch_info, node)
open_files(&range, &fetch_info, reqctx.reqid(), node)
};
Self {
file_chan,