Page MenuHomePhabricator

[backup-client] Downloading logs
ClosedPublic

Authored by michal on Jan 4 2024, 7:30 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 13, 9:43 PM
Unknown Object (File)
Thu, Dec 12, 5:26 PM
Unknown Object (File)
Sun, Dec 1, 1:54 AM
Unknown Object (File)
Nov 16 2024, 7:34 PM
Unknown Object (File)
Nov 16 2024, 7:33 PM
Unknown Object (File)
Nov 16 2024, 7:33 PM
Unknown Object (File)
Nov 16 2024, 7:33 PM
Unknown Object (File)
Nov 16 2024, 7:28 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
No Lint Coverage
Unit
No Test Coverage

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.