Page MenuHomePhabricator

D13655.id45069.diff
No OneTemporary

D13655.id45069.diff

diff --git a/lib/facts/blob-service.js b/lib/facts/blob-service.js
--- a/lib/facts/blob-service.js
+++ b/lib/facts/blob-service.js
@@ -35,6 +35,10 @@
path: '/blob',
method: 'DELETE',
},
+ REMOVE_MULTIPLE_HOLDERS: {
+ path: '/holders',
+ method: 'DELETE',
+ },
});
const config: BlobServiceConfig = {
diff --git a/lib/types/blob-service-types.js b/lib/types/blob-service-types.js
new file mode 100644
--- /dev/null
+++ b/lib/types/blob-service-types.js
@@ -0,0 +1,78 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import { tShape } from '../utils/validation-utils.js';
+
+/*
+ * This file defines types and validation for HTTP requests and responses
+ * for the Blob Service. The definitions in this file should remain in sync
+ * with the structures defined in the `http` submodule of the corresponding
+ * Rust file at `shared/comm-lib/src/blob/types.rs`.
+ *
+ * If you edit the definitions in one file,
+ * please make sure to update the corresponding definitions in the other.
+ */
+
+export type BlobInfo = {
+ +blobHash: string,
+ +holder: string,
+};
+export const blobInfoValidator: TInterface<BlobInfo> = tShape<BlobInfo>({
+ blobHash: t.String,
+ holder: t.String,
+});
+
+export type HolderAssignmentResult = $ReadOnly<{
+ ...BlobInfo,
+ // `true` if adding this holder was successful.
+ // Also true when `holderAlreadyExists` is true.
+ +success: boolean,
+ // `true` when given holder already existed
+ +holderAlreadyExists: boolean,
+ // `true` if blob hash has been uploaded before.
+ +dataExists: boolean,
+}>;
+export const holderAssignmentResultValidator: TInterface<HolderAssignmentResult> =
+ tShape<HolderAssignmentResult>({
+ blobHash: t.String,
+ holder: t.String,
+ success: t.Boolean,
+ holderAlreadyExists: t.Boolean,
+ dataExists: t.Boolean,
+ });
+
+export type AssignHoldersRequest = {
+ +requests: $ReadOnlyArray<BlobInfo>,
+};
+
+export type AssignHoldersResponse = {
+ +results: $ReadOnlyArray<HolderAssignmentResult>,
+};
+export const assignHoldersResponseValidator: TInterface<AssignHoldersResponse> =
+ tShape<AssignHoldersResponse>({
+ results: t.list(holderAssignmentResultValidator),
+ });
+
+type RemoveHolderItemsRequest = {
+ +requests: $ReadOnlyArray<BlobInfo>,
+ // Whether to instantly delete blob after last holder is removed, without
+ // waiting for cleanup. Defaults to `false` if not provided.
+ +instantDelete?: boolean,
+};
+type RemoveHoldersByTagRequest = {
+ +tags: $ReadOnlyArray<string>,
+};
+export type RemoveHoldersRequest =
+ | RemoveHolderItemsRequest
+ | RemoveHoldersByTagRequest;
+
+export type RemoveHoldersResponse = {
+ // Holder removal requests that failed server-side are returned here.
+ // This can be passed into retry request body.
+ +failedRequests: $ReadOnlyArray<BlobInfo>,
+};
+export const removeHoldersResponseValidator: TInterface<RemoveHoldersResponse> =
+ tShape<RemoveHoldersResponse>({
+ failedRequests: t.list(blobInfoValidator),
+ });
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
@@ -3,6 +3,13 @@
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
+/// This module defines structures for HTTP requests and responses
+/// for the Blob Service. The definitions in this file should remain in sync
+/// with the types and validators defined in the corresponding
+/// JavaScript file at `lib/types/blob-service-types.js`.
+///
+/// If you edit the definitions in one file,
+/// please make sure to update the corresponding definitions in the other.
pub mod http {
use serde::{Deserialize, Serialize};

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 17, 5:22 AM (14 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2304359
Default Alt Text
D13655.id45069.diff (3 KB)

Event Timeline