Page MenuHomePhabricator

[backup-client] Downloading logs
ClosedPublic

Authored by michal on Jan 4 2024, 7:30 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jul 4, 12:05 AM
Unknown Object (File)
Wed, Jul 3, 1:22 AM
Unknown Object (File)
Mon, Jul 1, 6:32 PM
Unknown Object (File)
Mon, Jul 1, 2:36 AM
Unknown Object (File)
Sun, Jun 30, 8:42 PM
Unknown Object (File)
Sun, Jun 30, 7:55 AM
Unknown Object (File)
Wed, Jun 26, 3:47 PM
Unknown Object (File)
Mon, Jun 24, 11:35 PM
Subscribers

Details

Summary

ENG-5558 : Add support for downloading logs from backup client

Implemented function for log download. The stream/sink from tungstenite is mapped so that the clients only deal with business logic. The reconnection etc. will be handled in the outside code.

Depends on D10532

Test Plan

Tested with next diffs from commtest and native mobile devices. Tested with this code:

let (tx, rx) = backup_client
  .download_logs(&user_identity, &backup_data.backup_id)
  .await
  .unwrap();

tokio::pin!(tx);
tokio::pin!(rx);

tx.send(DownloadLogsRequest { from_id: None })
  .await
  .unwrap();

'download: loop {
  loop {
    match rx.next().await.unwrap().unwrap() {
      LogWSResponse::LogDownload {
        log_id,
        content,
        attachments,
      } => {
        // check correctness
      }
      LogWSResponse::LogDownloadFinished { last_log_id } => {
        if let Some(last_log_id) = last_log_id {
          tx.send(DownloadLogsRequest {
            from_id: Some(last_log_id),
          })
          .await
          .unwrap();
        } else {
          break 'download;
        }
      }
      msg => panic!("Got response: {msg:?}"),
    };
  }
}
// check that all logs were downloaded

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

michal requested review of this revision.Jan 4 2024, 7:47 AM

Lots of this code overlaps with upload_logs() but I assume it cannot be easily deduped without macros/other hacking

This revision is now accepted and ready to land.Jan 5 2024, 3:11 AM

Removed a bit of code duplication for parsing ws messages

This revision was landed with ongoing or failed builds.Jan 8 2024, 7:20 AM
This revision was automatically updated to reflect the committed changes.