mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-30 13:35:04 +02:00
rename send -> try_send
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
+13
-4
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user