remove anyhow refs & implement missing errors

This commit is contained in:
marin postma 2021-06-14 21:26:35 +02:00
parent c1b6f0e833
commit 58f9974be4
No known key found for this signature in database
GPG key ID: 6088B7721C3E39F9
40 changed files with 707 additions and 668 deletions

View file

@ -10,8 +10,9 @@ use tokio::sync::{mpsc, oneshot, RwLock};
use update_actor::UpdateActorHandle;
use uuid_resolver::UuidResolverHandle;
use super::{DumpError, DumpInfo, DumpMsg, DumpResult, DumpStatus, DumpTask};
use super::{DumpInfo, DumpMsg, DumpStatus, DumpTask};
use crate::index_controller::{update_actor, uuid_resolver};
use super::error::{DumpActorError, Result};
pub const CONCURRENT_DUMP_MSG: usize = 10;
@ -95,14 +96,14 @@ where
}
}
async fn handle_create_dump(&self, ret: oneshot::Sender<DumpResult<DumpInfo>>) {
async fn handle_create_dump(&self, ret: oneshot::Sender<Result<DumpInfo>>) {
let uid = generate_uid();
let info = DumpInfo::new(uid.clone(), DumpStatus::InProgress);
let _lock = match self.lock.try_lock() {
Some(lock) => lock,
None => {
ret.send(Err(DumpError::DumpAlreadyRunning))
ret.send(Err(DumpActorError::DumpAlreadyRunning))
.expect("Dump actor is dead");
return;
}
@ -147,10 +148,10 @@ where
};
}
async fn handle_dump_info(&self, uid: String) -> DumpResult<DumpInfo> {
async fn handle_dump_info(&self, uid: String) -> Result<DumpInfo> {
match self.dump_infos.read().await.get(&uid) {
Some(info) => Ok(info.clone()),
_ => Err(DumpError::DumpDoesNotExist(uid)),
_ => Err(DumpActorError::DumpDoesNotExist(uid)),
}
}
}