integrate the search batcher in the tick

This commit is contained in:
Tamo 2021-10-19 19:17:16 +02:00 committed by marin postma
parent d3d76bf97a
commit 35ffd0ec3a
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9
1 changed files with 11 additions and 1 deletions

View File

@ -143,7 +143,17 @@ mod segment {
})
.await;
}
let _ = self.batcher.lock().await.flush().await;
let get_search = std::mem::take(&mut *self.get_search_batcher.lock().await)
.into_event(self.user.clone(), "Documents Searched GET".to_string());
let post_search = std::mem::take(&mut *self.post_search_batcher.lock().await)
.into_event(self.user.clone(), "Documents Searched POST".to_string());
// keep the lock on the batcher just for these three operations
{
let mut batcher = self.batcher.lock().await;
let _ = batcher.push(get_search).await;
let _ = batcher.push(post_search).await;
let _ = self.batcher.lock().await.flush().await;
}
println!("ANALYTICS: sent the batch");
tokio::time::sleep(Duration::from_secs(60 * 5)).await; // 5 minutes
}