Page MenuHomePhabricator

D6240.id21110.diff
No OneTemporary

D6240.id21110.diff

diff --git a/services/backup/src/service/handlers/pull_backup.rs b/services/backup/src/service/handlers/pull_backup.rs
new file mode 100644
--- /dev/null
+++ b/services/backup/src/service/handlers/pull_backup.rs
@@ -0,0 +1,34 @@
+use tokio_stream::Stream;
+use tonic::Status;
+
+use super::proto::{self, PullBackupResponse};
+use crate::database::{BackupItem, DatabaseClient, LogItem};
+
+pub struct PullBackupHandler {
+ backup_item: BackupItem,
+ logs: Vec<LogItem>,
+}
+
+impl PullBackupHandler {
+ pub async fn new(
+ db: &DatabaseClient,
+ request: proto::PullBackupRequest,
+ ) -> Result<Self, Status> {
+ unimplemented!()
+ }
+
+ /// Consumes the handler and provides a response `Stream`. The stream will
+ /// produce the following in order:
+ /// - Backup compaction data chunks
+ /// - Backup logs
+ /// - Whole log, if stored in db
+ /// - Log chunks, if stored in blob
+ pub fn into_response_stream(
+ self,
+ ) -> impl Stream<Item = Result<PullBackupResponse, Status>> {
+ // the unimplemented!() macro doesnt compile here
+ async_stream::stream! {
+ yield Err(Status::unimplemented("not implemented yet"))
+ }
+ }
+}
diff --git a/services/backup/src/service/mod.rs b/services/backup/src/service/mod.rs
--- a/services/backup/src/service/mod.rs
+++ b/services/backup/src/service/mod.rs
@@ -20,6 +20,7 @@
mod handlers {
pub(super) mod add_attachments;
pub(super) mod create_backup;
+ pub(super) mod pull_backup;
pub(super) mod send_log;
// re-exports for convenient usage in handlers
@@ -27,6 +28,7 @@
pub(self) use super::proto;
}
use self::handlers::create_backup::CreateBackupHandler;
+use self::handlers::pull_backup::PullBackupHandler;
use self::handlers::send_log::SendLogHandler;
pub struct MyBackupService {
@@ -172,12 +174,18 @@
Box<dyn Stream<Item = Result<proto::PullBackupResponse, Status>> + Send>,
>;
- #[instrument(skip(self))]
+ #[instrument(skip_all, fields(backup_id = &request.get_ref().backup_id))]
async fn pull_backup(
&self,
- _request: Request<proto::PullBackupRequest>,
+ request: Request<proto::PullBackupRequest>,
) -> Result<Response<Self::PullBackupStream>, Status> {
- Err(Status::unimplemented("unimplemented"))
+ info!("PullBackup request: {:?}", request);
+
+ let handler =
+ PullBackupHandler::new(&self.db, request.into_inner()).await?;
+
+ let stream = handler.into_response_stream();
+ Ok(Response::new(Box::pin(stream) as Self::PullBackupStream))
}
#[instrument(skip_all,

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 1:43 AM (13 m, 20 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2679519
Default Alt Text
D6240.id21110.diff (2 KB)

Event Timeline