Skip to content

Commit 99bfc9d

Browse files
Add task polling
1 parent b843db2 commit 99bfc9d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/server.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ impl Service {
236236
Some(hnsw).cloned()
237237
} else {
238238
let mut path = self.path.clone();
239-
dbg!(index_id);
240239
match deserialize_index(&mut path, index_id, &self.vector_store) {
241240
Ok(res) => Some(res.into()),
242241
Err(_) => None,
@@ -245,7 +244,7 @@ impl Service {
245244
}
246245

247246
async fn set_index(&self, index_id: String, hnsw: Arc<HnswIndex>) {
248-
self.indexes.write().await.insert(dbg!(index_id), hnsw);
247+
self.indexes.write().await.insert(index_id, hnsw);
249248
}
250249

251250
async fn test_and_set_pending(&self, index_id: String) -> bool {
@@ -327,7 +326,7 @@ impl Service {
327326
self.set_index(id, hnsw.into()).await;
328327
self.clear_pending(&index_id).await;
329328
}
330-
self.set_task_status(task_id, TaskStatus::Completed)
329+
self.set_task_status(task_id, TaskStatus::Completed).await;
331330
});
332331
}
333332

@@ -373,7 +372,8 @@ impl Service {
373372
previous,
374373
}) => {
375374
let task_id = Service::generate_task();
376-
self.set_task_status(task_id.clone(), TaskStatus::Pending);
375+
self.set_task_status(task_id.clone(), TaskStatus::Pending)
376+
.await;
377377
self.start_indexing(domain, commit, previous, task_id.clone());
378378
Ok(Response::builder().body(task_id.into()).unwrap())
379379
}
@@ -383,7 +383,9 @@ impl Service {
383383
.body(format!("{:?}", state).into())
384384
.unwrap())
385385
} else {
386-
Ok(Response::builder().body("Completed".into()).unwrap())
386+
Ok(Response::builder()
387+
.body(format!("{:?}", TaskStatus::Completed).into())
388+
.unwrap())
387389
}
388390
}
389391
Ok(ResourceSpec::Similar {

0 commit comments

Comments
 (0)