The Blob Database is a collection of stores each containing multiple content-addressible blobs. A blob is binary data (i.e. the contents of a file).
These functions operate at the global database scope.
store_list() -> StoreName[]
Output the names of all stores in the database.
store_create(StoreName) -> Status
Create a store with the given name.
store_destroy(StoreName) -> Status
Destroy the store with the given name and all blobs within the given store.
Note: As one would expect, this does not affect duplicates of any of said blobs in other stores.
blob_hash(Blob) -> Hash
Output the hash of the given blob.
Note: This simply implements the sha256 algorithm, which a client can almost certainly do faster itself.
These functions all operate on the blobs within the given store.
blob_load(StoreName, Hash) -> Blob | Status
Output the contents of the blob with the given hash in the given store.
blob_save(StoreName, Blob) -> (Status, Hash)
Save the given blob to the given store. Output the hash to be used as a handle for subsequent load and remove operations. The hash is always computed and outputted for valid requests.
Note: Some clients may wish to include special logic for the
already-exists status code if they intend to sometimes save duplicate blobs.
(As a content-addressible store naturally performs de-duplication, a save of
a duplicate blob is a no-op.)
blob_info(StoreName, Hash) -> Status
Determine whether the blob with the given hash exists in the given store.
Outputs okay if it exists, not-found otherwise.
blob_list(StoreName) -> Hash[] | Status
Output the hash of all blobs in the given store.
blob_delete(StoreName, Hash) -> Status
Delete the blob with the given hash from the given store.
The name of a store (i.e. a string), used as a unique identifier for referring to said store.
A blob is a variably-sized array of bytes. This concept is equivalent to the contents of a file.
The sha256 hash of a Blob, which is a fixed-sized array of 32 bytes.
A status enumeration, which is one of:
- okay: The operation was successful.
- not-found: The blob with the given hash or the store with the given name was not found.
- already-exists: The blob with the given hash or the store with the given name already exists.
- no-space: Save failed due to insufficient storage space.
- internal-error: The operation failed because of an internal failure in the server. (This shouldn't normally happen.)
RequestStream = {OPEN_DOOR, proto_version: uint32, requests: Request*}
ResponseStream = {WELCOME, responses: Response*}
| {NOT_WELCOME, proto_version: uint32}
Request = {STORE_LIST}
| {STORE_CREATE, StoreName}
| {STORE_DESTROY, StoreName}
| {BLOB_HASH, Blob}
| {BLOB_LIST, StoreName}
| {BLOB_INFO, StoreName, Hash}
| {BLOB_LOAD, StoreName, Hash}
| {BLOB_SAVE, StoreName, Blob}
| {BLOB_DELETE, StoreName, Hash}
Response = Status
| StoreListResponse
| BlobHashResponse
| BlobListResponse
| BlobLoadResponse
| BlobSaveResponse
StoreListResponse = {OK, StoreNames} | ErrorStatus
BlobHashResponse = {OK, Hash} | ErrorStatus
BlobListResponse = {OK, Hashes} | ErrorStatus
BlobLoadResponse = {OK, Blob} | ErrorStatus
BlobSaveResponse = {OK | ALREADY_EXISTS | NO_SPACE, Hash} | INVALID_ARGUMENT
StoreName = {size: uint16, elems: [size x uint8]}
StoreNames = {size: uint64, elems: [size x StoreName]}
Blob = {size: uint64, elems: [size x uint8]}
Hash = [32 x uint8]
Hashes = {size: uint64, elems: [size x Hash]}
Status = OKAY | ErrorStatus
ErrorStatus = NOT_FOUND
| ALREADY_EXISTS
| INVALID_ARGUMENT
| NO_SPACE
| INTERNAL_ERROR
| Cap'n Proto
v
+-----------+
| Interface |
+-----------+
| Storage |
+-----------+
|
| filesystem
| operations
v
(-----------)
| Disk |
(-----------)