HomePhabricator
Diffusion Comm 1688c9d7501f

[backup-client] Downloading logs

Description

[backup-client] Downloading logs

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

Reviewers: bartek, kamil

Reviewed By: bartek

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D10533

Details

Provenance
Michal Gniadek <michal.gniadek@swmansion.com>Authored on Jan 4 2024, 7:17 AM
Reviewer
bartek
Differential Revision
D10533: [backup-client] Downloading logs
Parents
rCOMMbcd0dd5b01b7: [backup-client] Uploading logs
Branches
Unknown
Tags
Unknown

Event Timeline

Michal Gniadek <michal.gniadek@swmansion.com> committed rCOMM1688c9d7501f: [backup-client] Downloading logs (authored by Michal Gniadek <michal.gniadek@swmansion.com>).Jan 8 2024, 7:20 AM