Skip to content

Commit b843db2

Browse files
Adding task status
1 parent de83ba4 commit b843db2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
173173
let lines = io::BufReader::new(f).lines();
174174
let opstream = &lines
175175
.map(|l| {
176-
dbg!(&l);
177176
let ro: io::Result<Operation> = serde_json::from_str(&l.unwrap())
178177
.map_err(|e| std::io::Error::new(ErrorKind::Other, e));
179178
ro

src/server.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,13 @@ impl Service {
303303
}
304304
}
305305

306-
fn start_indexing(self: Arc<Self>, domain: String, commit: String, previous: Option<String>) {
306+
fn start_indexing(
307+
self: Arc<Self>,
308+
domain: String,
309+
commit: String,
310+
previous: Option<String>,
311+
task_id: String,
312+
) {
307313
tokio::spawn(async move {
308314
let index_id = create_index_name(&domain, &commit);
309315
if self.test_and_set_pending(index_id.clone()).await {
@@ -321,6 +327,7 @@ impl Service {
321327
self.set_index(id, hnsw.into()).await;
322328
self.clear_pending(&index_id).await;
323329
}
330+
self.set_task_status(task_id, TaskStatus::Completed)
324331
});
325332
}
326333

@@ -366,7 +373,8 @@ impl Service {
366373
previous,
367374
}) => {
368375
let task_id = Service::generate_task();
369-
self.start_indexing(domain, commit, previous);
376+
self.set_task_status(task_id.clone(), TaskStatus::Pending);
377+
self.start_indexing(domain, commit, previous, task_id.clone());
370378
Ok(Response::builder().body(task_id.into()).unwrap())
371379
}
372380
Ok(ResourceSpec::CheckTask { task_id }) => {

0 commit comments

Comments
 (0)