Skip to content

Commit

Permalink
fix: log count of deleted documents at start
Browse files Browse the repository at this point in the history
  • Loading branch information
cailloumajor committed Jan 15, 2023
1 parent ee4a564 commit 9fea2a9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use anyhow::{Context as _, Result};
use futures_util::FutureExt;
use mongodb::bson::{self, doc, DateTime, Document};
use mongodb::options::{ClientOptions, UpdateOptions};
use mongodb::results::DeleteResult;
use mongodb::{Client, Database};
use tracing::{debug, debug_span, error, info, info_span, Instrument};

Expand Down Expand Up @@ -56,10 +57,13 @@ impl Actor for DatabaseActor {
let query = doc! { "_id": &document_id };
ctx.wait(
async move {
if let Err(err) = collection.delete_one(query, None).await {
error!(when = "deleting document", document_id, %err);
} else {
info!(status = "deleted", document_id);
match collection.delete_one(query, None).await {
Ok(DeleteResult { deleted_count, .. }) => {
info!(status = "deleted", document_id, deleted_count);
}
Err(err) => {
error!(when = "deleting document", document_id, %err);
}
}
}
.instrument(info_span!("database_actor_started_hook"))
Expand Down

0 comments on commit 9fea2a9

Please sign in to comment.