[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