@cloudbitmaps/gcs 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -4
- package/dist/backend.d.ts +32 -3
- package/dist/download-retry.d.ts +8 -0
- package/dist/gcs-errors.d.ts +16 -1
- package/dist/index.js +498 -74
- package/dist/index.js.map +4 -4
- package/dist/read-once.d.ts +52 -0
- package/dist/read-timeout.d.ts +28 -0
- package/dist/registry.d.ts +50 -9
- package/dist/storage.d.ts +50 -2
- package/package.json +2 -2
package/dist/storage.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import type { BlobSink, GenKey, IStorageDriver, SegmentRef, StorageCaps } from '@cloudbitmaps/core/driver-kit';
|
|
2
2
|
import type { Storage } from '@google-cloud/storage';
|
|
3
|
+
/** What the throttle backoff waits on. */
|
|
4
|
+
interface Sleeper {
|
|
5
|
+
sleep(ms: number): Promise<void>;
|
|
6
|
+
}
|
|
3
7
|
export interface GcsStorageDriverOptions {
|
|
4
8
|
/** A constructed `@google-cloud/storage` `Storage` client (point `apiEndpoint` at fake-gcs-server locally). */
|
|
5
9
|
readonly storage: Storage;
|
|
10
|
+
/**
|
|
11
|
+
* The client the downloads go through; `storage` when absent. `GcsStorage` passes one built with the SDK's request
|
|
12
|
+
* retries off (the read client built in its constructor), because a download the SDK retries can crash the process;
|
|
13
|
+
* the driver retries a download itself instead.
|
|
14
|
+
*/
|
|
15
|
+
readonly readStorage?: Storage;
|
|
6
16
|
/** Target bucket (must already exist). */
|
|
7
17
|
readonly bucket: string;
|
|
8
18
|
/** Optional object-name prefix under which all objects live (e.g. `cloudbitmaps/`). */
|
|
@@ -12,25 +22,62 @@ export interface GcsStorageDriverOptions {
|
|
|
12
22
|
/** Bytes at/under which a single non-resumable upload is used instead of a resumable stream (default 8 MiB).
|
|
13
23
|
* Must be a positive safe integer. */
|
|
14
24
|
readonly simpleUploadThresholdBytes?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Cut off a read that has run this long, in milliseconds: a tail read (with the metadata read it falls back on for
|
|
27
|
+
* an empty object) or a range read, every attempt and the backoff between them included. `0` (the default) sets no
|
|
28
|
+
* timeout. The clock starts at the call into the driver, so a credential fetch counts, and runs until the body has
|
|
29
|
+
* ended; when it passes the read throws `TransientError` and no further attempt starts. Uploads, deletes and
|
|
30
|
+
* listings are not timed. A non-negative safe integer no larger than 2,147,483,647.
|
|
31
|
+
*/
|
|
32
|
+
readonly readTimeoutMs?: number;
|
|
33
|
+
/** What the backoff before re-sending a throttled upload waits on; real time when absent. */
|
|
34
|
+
readonly clock?: Sleeper;
|
|
15
35
|
}
|
|
16
36
|
export declare class GcsStorageDriver implements IStorageDriver {
|
|
17
37
|
private readonly storage;
|
|
38
|
+
private readonly readStorage;
|
|
18
39
|
private readonly bucket;
|
|
19
40
|
private readonly prefix;
|
|
20
41
|
private readonly maxObjectBytes;
|
|
21
42
|
private readonly threshold;
|
|
43
|
+
private readonly readTimeoutMs;
|
|
44
|
+
private readonly clock;
|
|
22
45
|
constructor(options: GcsStorageDriverOptions);
|
|
23
46
|
capabilities(): StorageCaps;
|
|
24
47
|
private file;
|
|
48
|
+
/** The same object on the download client, off the SDK's shared agent ({@link downloadFile}). */
|
|
49
|
+
private downloadable;
|
|
50
|
+
/** The deadline a read of `key` made now runs under, every attempt included, named for its error; none when off. */
|
|
51
|
+
private deadline;
|
|
25
52
|
putImmutable(key: GenKey, write: (sink: BlobSink) => Promise<void>): Promise<{
|
|
26
53
|
size: number;
|
|
27
54
|
sha256: string;
|
|
28
55
|
}>;
|
|
29
56
|
getRange(key: GenKey, offset: number, length: number): Promise<Uint8Array>;
|
|
57
|
+
/**
|
|
58
|
+
* Refuse a range response unless it is exactly the bytes asked for. A 206 must name them in `Content-Range: bytes
|
|
59
|
+
* a-b/total`, starting at `offset`, and hold that many; a 200 (a server that ignored the range) is the whole object,
|
|
60
|
+
* which is the range only when the range starts at 0. A short read means the range ran past the end of the object:
|
|
61
|
+
* out of bounds, never a partial result.
|
|
62
|
+
*/
|
|
63
|
+
private checkRange;
|
|
64
|
+
private badRange;
|
|
30
65
|
getTail(key: GenKey, maxBytes: number): Promise<{
|
|
31
66
|
bytes: Uint8Array;
|
|
32
67
|
size: number;
|
|
33
68
|
}>;
|
|
69
|
+
/**
|
|
70
|
+
* The object's size from its metadata, validated. Read on the download client and retried as a download is, within
|
|
71
|
+
* the calling read's `deadline` ({@link withDeadline}), so nothing but the one request in flight runs past it.
|
|
72
|
+
*/
|
|
73
|
+
private sizeOf;
|
|
74
|
+
/**
|
|
75
|
+
* The object's total size from a tail response, refused unless every header agrees with the bytes received. A 206
|
|
76
|
+
* must carry `Content-Range: bytes a-b/total` that names exactly the suffix asked for and exactly the bytes held;
|
|
77
|
+
* a 200 (a server that ignored the range) is the whole object, and is accepted only when it fits in the request.
|
|
78
|
+
*/
|
|
79
|
+
private tailSize;
|
|
80
|
+
private badTail;
|
|
34
81
|
delete(key: GenKey): Promise<void>;
|
|
35
82
|
list(ref: SegmentRef): AsyncIterable<GenKey>;
|
|
36
83
|
/** Map GCS read errors to the driver vocabulary; pass everything else through {@link mapError}. */
|
|
@@ -38,8 +85,9 @@ export declare class GcsStorageDriver implements IStorageDriver {
|
|
|
38
85
|
/**
|
|
39
86
|
* Reclassify a transient GCS fault (throttle/5xx/dropped connection) as a retryable {@link TransientError},
|
|
40
87
|
* so the store's read retry can ride it out and a write's caller can tell it from a deterministic failure;
|
|
41
|
-
* everything else propagates unchanged. The final fallback at every client-call site
|
|
42
|
-
*
|
|
88
|
+
* everything else propagates unchanged. The final fallback at every client-call site: an HTTP status and a fault
|
|
89
|
+
* in transit arrive typed, and anything else (a checksum mismatch, a credentials failure) as the SDK raised it.
|
|
43
90
|
*/
|
|
44
91
|
private mapError;
|
|
45
92
|
}
|
|
93
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbitmaps/gcs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Google Cloud Storage for CloudBitmaps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudbitmaps",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@google-cloud/storage": "^7 || ^8",
|
|
52
|
-
"@cloudbitmaps/core": "^0.
|
|
52
|
+
"@cloudbitmaps/core": "^0.12.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^22.0.0",
|