Page MenuHomePhabricator

[backup-client] Uploading logs
ClosedPublic

Authored by michal on Jan 4 2024, 7:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 22, 10:08 PM
Unknown Object (File)
Sun, Dec 22, 10:08 PM
Unknown Object (File)
Sun, Dec 22, 10:08 PM
Unknown Object (File)
Sun, Dec 22, 10:08 PM
Unknown Object (File)
Sun, Dec 22, 10:07 PM
Unknown Object (File)
Fri, Dec 20, 1:04 PM
Unknown Object (File)
Fri, Dec 20, 1:01 PM
Unknown Object (File)
Fri, Dec 20, 12:55 PM
Subscribers

Details

Summary

ENG-5557 : Add support for uploading logs from backup clients

This diff adds an option to create a websocket connection, upload logs and receive upload confirmations from the backup service. 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 D10457

Test Plan

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

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

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

for log_data in log_datas {
  tx.send(log_data.clone()).await.unwrap();
}

let result: HashSet<usize> =
  rx.take(log_datas.len()).try_collect().await.unwrap();
let expected = log_datas.iter().map(|data| data.log_id).collect();
assert_eq!(result, expected);

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

shared/backup_client/Cargo.toml
18–20

All of these dependencies (with these specific versions) are already used elsewhere in our codebase.

michal requested review of this revision.Jan 4 2024, 7:45 AM
bartek added inline comments.
shared/backup_client/src/lib.rs
138–142

Does this block have to be async if there are no async calls inside?

161–164

You probably don't need returns here

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

Remove return

shared/backup_client/src/lib.rs
138–142

Yes, with expects a future. An alternative would be to use a ready future but I think using async is cleaner.

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.