Page MenuHomePhabricator

[services-lib] Add methods to manage blob holders
ClosedPublic

Authored by bartek on Aug 10 2023, 10:27 AM.
Tags
None
Referenced Files
F3366203: D8780.diff
Mon, Nov 25, 10:06 AM
Unknown Object (File)
Sat, Nov 23, 1:58 PM
Unknown Object (File)
Sat, Nov 23, 12:59 PM
Unknown Object (File)
Mon, Nov 18, 2:07 PM
Unknown Object (File)
Wed, Nov 13, 8:07 PM
Unknown Object (File)
Sun, Nov 10, 9:35 PM
Unknown Object (File)
Tue, Oct 29, 11:10 PM
Unknown Object (File)
Sun, Oct 27, 4:46 PM
Subscribers

Details

Summary

Part of ENG-4597.

Added functions to add / revoke blob holders for a blob. Also, added a simple utility function to create a holder and upload a blob if it doesn't exist - this is the most common usecase.

Depends on D8779

Test Plan

Test code

let client = BlobServiceClient::new("http://localhost:50053".parse()?);

let blob_hash = "hello".to_string();
let holder = "world".to_string();

let stream = async_stream::stream! {
  yield Result::<Vec<u8>, std::io::Error>::Ok(vec![1, 2, 3]);
  yield Ok(vec![4, 5, 6]);
  yield Err(std::io::Error::new(std::io::ErrorKind::Other, "test"));
};

client.assign_holder(&blob_hash, &holder).await?;
client.upload_blob(&blob_hash, stream).await.map_err(|e| {
  println!("Error: {0:?} --- {0}", e);
  e
})?;

let mut stream = client.get("hello").await?;
while let Some(data) = stream.try_next().await? {
  println!("Got data: {:?}", data);
}

client.revoke_holder(&blob_hash, &holder).await?;

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
services/comm-services-lib/src/blob/client.rs
299 ↗(On Diff #29820)
bartek published this revision for review.Aug 11 2023, 2:20 AM
services/comm-services-lib/src/blob/client.rs
136 ↗(On Diff #29820)

I don't think this is needed

149 ↗(On Diff #29820)

nit

This revision is now accepted and ready to land.Aug 11 2023, 4:35 AM