Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2988246
D13655.id45073.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13655.id45073.diff
View Options
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
@@ -2,6 +2,13 @@
use hex::ToHex;
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 17, 4:32 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2295936
Default Alt Text
D13655.id45073.diff (3 KB)
Attached To
Mode
D13655: [lib] Add types for Blob Service requests and responses
Attached
Detach File
Event Timeline
Log In to Comment