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
Unknown Object (File)
Fri, May 10, 12:40 AM
Unknown Object (File)
Mon, May 6, 4:52 PM
Unknown Object (File)
Sun, May 5, 3:02 AM
Unknown Object (File)
Sat, May 4, 4:51 PM
Unknown Object (File)
Sat, May 4, 1:02 PM
Unknown Object (File)
Apr 4 2024, 1:05 PM
Unknown Object (File)
Apr 4 2024, 1:05 PM
Unknown Object (File)
Apr 4 2024, 1:05 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
Lint Not Applicable
Unit
Tests Not Applicable

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