2021-05-10 20:25:09 +02:00
|
|
|
use tokio::sync::{mpsc, oneshot};
|
|
|
|
|
2021-06-14 21:26:35 +02:00
|
|
|
use super::error::Result;
|
2021-12-02 16:03:26 +01:00
|
|
|
use super::{DumpActorHandle, DumpInfo, DumpMsg};
|
2021-05-31 16:40:59 +02:00
|
|
|
|
2021-05-10 20:25:09 +02:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct DumpActorHandleImpl {
|
2021-12-02 16:03:26 +01:00
|
|
|
pub sender: mpsc::Sender<DumpMsg>,
|
2021-05-10 20:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl DumpActorHandle for DumpActorHandleImpl {
|
2021-06-14 21:26:35 +02:00
|
|
|
async fn create_dump(&self) -> Result<DumpInfo> {
|
2021-05-10 20:25:09 +02:00
|
|
|
let (ret, receiver) = oneshot::channel();
|
|
|
|
let msg = DumpMsg::CreateDump { ret };
|
|
|
|
let _ = self.sender.send(msg).await;
|
|
|
|
receiver.await.expect("IndexActor has been killed")
|
|
|
|
}
|
|
|
|
|
2021-06-14 21:26:35 +02:00
|
|
|
async fn dump_info(&self, uid: String) -> Result<DumpInfo> {
|
2021-05-10 20:25:09 +02:00
|
|
|
let (ret, receiver) = oneshot::channel();
|
|
|
|
let msg = DumpMsg::DumpInfo { ret, uid };
|
|
|
|
let _ = self.sender.send(msg).await;
|
|
|
|
receiver.await.expect("IndexActor has been killed")
|
|
|
|
}
|
|
|
|
}
|