Page MenuHomePhabricator

D13619.diff
No OneTemporary

D13619.diff

diff --git a/services/blob/src/http/handlers/holders.rs b/services/blob/src/http/handlers/holders.rs
--- a/services/blob/src/http/handlers/holders.rs
+++ b/services/blob/src/http/handlers/holders.rs
@@ -3,7 +3,8 @@
use comm_lib::auth::AuthorizationCredential;
use comm_lib::blob::types::http::{
AssignHoldersRequest, AssignHoldersResponse, BlobInfo,
- HolderAssignmentResult, RemoveHoldersRequest, RemoveHoldersResponse,
+ HolderAssignmentResult, HoldersQueryResponse, HoldersQueryUrlParams,
+ RemoveHoldersRequest, RemoveHoldersResponse,
};
use tracing::{info, instrument, trace, warn};
@@ -105,6 +106,21 @@
Ok(HttpResponse::Ok().json(web::Json(response)))
}
+#[instrument(name = "query_holders", skip_all)]
+pub async fn query_holders_handler(
+ service: web::Data<BlobService>,
+ query: web::Query<HoldersQueryUrlParams>,
+ requesting_identity: AuthorizationCredential,
+) -> actix_web::Result<HttpResponse> {
+ verify_caller_is_service(&requesting_identity)?;
+
+ let HoldersQueryUrlParams { prefix } = query.into_inner();
+ let items = service.query_indexed_holders(prefix).await?;
+
+ let response = HoldersQueryResponse { items };
+ Ok(HttpResponse::Ok().json(web::Json(response)))
+}
+
/**
* Returns `HTTP 400 Bad Request` if one or more blob hashes or holders
* have invalid format. See [`comm_lib::tools::is_valid_identifier`] for
diff --git a/services/blob/src/http/mod.rs b/services/blob/src/http/mod.rs
--- a/services/blob/src/http/mod.rs
+++ b/services/blob/src/http/mod.rs
@@ -48,6 +48,7 @@
.service(
web::resource("/holders")
.wrap(auth_middleware)
+ .route(web::get().to(handlers::holders::query_holders_handler))
.route(web::post().to(handlers::holders::assign_holders_handler))
.route(web::delete().to(handlers::holders::remove_holders_handler)),
)
diff --git a/shared/comm-lib/src/blob/types.rs b/shared/comm-lib/src/blob/types.rs
--- a/shared/comm-lib/src/blob/types.rs
+++ b/shared/comm-lib/src/blob/types.rs
@@ -55,6 +55,16 @@
pub failed_requests: Vec<BlobInfo>,
}
+ // Query holders by prefix
+ #[derive(Serialize, Deserialize, Debug)]
+ pub struct HoldersQueryUrlParams {
+ pub prefix: String,
+ }
+ #[derive(Serialize, Deserialize, Debug)]
+ pub struct HoldersQueryResponse {
+ pub items: Vec<BlobInfo>,
+ }
+
// Single holder endpoint types
#[derive(Serialize, Deserialize, Debug)]

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 4:46 PM (17 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2562792
Default Alt Text
D13619.diff (2 KB)

Event Timeline