rename send -> try_send

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-10-21 22:39:30 +07:00
parent fd148c6258
commit 8c574e8beb
2 changed files with 14 additions and 5 deletions
+13 -4
View File
@@ -113,16 +113,25 @@ impl CompactWorker {
}
}
pub async fn send(&self, parts: &Vec<ObjectPart<PartData>>) {
if parts.len() > CONFIG.compact_parts_limit {
pub async fn try_send(&self, parts: &Vec<ObjectPart<PartData>>) -> bool {
if parts.len() >= CONFIG.compact_parts_limit {
let task = CompactTask {
workspace: parts[0].data.workspace,
key: parts[0].data.key.clone(),
};
self.send(task).await
} else {
false
}
}
let res = self.ingest_tx.send(task.clone()).await;
if let Err(err) = res {
pub async fn send(&self, task: CompactTask) -> bool {
let res = self.ingest_tx.send(task).await;
match res {
Ok(_) => true,
Err(err) => {
warn!(%err, "failed to schedule compact");
false
}
}
}
+1 -1
View File
@@ -434,7 +434,7 @@ pub async fn get(request: HttpRequest) -> HandlerResult<HttpResponse> {
}
None => {
let compact = request.app_data::<Data<CompactWorker>>().unwrap();
compact.send(&parts).await;
compact.try_send(&parts).await;
let stream = merge::stream(s3.clone(), parts).await?;
response.body(SizedStream::new(stream.content_length, stream.stream))