@cloudbitmaps/gcs 0.11.2 → 0.13.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 +33 -1
- package/dist/backend.d.ts +29 -3
- package/dist/download-retry.d.ts +8 -2
- package/dist/gcs-errors.d.ts +6 -0
- package/dist/index.js +287 -61
- package/dist/index.js.map +4 -4
- package/dist/read-once.d.ts +16 -1
- package/dist/read-timeout.d.ts +28 -0
- package/dist/registry.d.ts +45 -5
- package/dist/storage.d.ts +32 -2
- package/package.json +2 -2
package/dist/storage.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
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;
|
|
@@ -18,6 +22,16 @@ export interface GcsStorageDriverOptions {
|
|
|
18
22
|
/** Bytes at/under which a single non-resumable upload is used instead of a resumable stream (default 8 MiB).
|
|
19
23
|
* Must be a positive safe integer. */
|
|
20
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;
|
|
21
35
|
}
|
|
22
36
|
export declare class GcsStorageDriver implements IStorageDriver {
|
|
23
37
|
private readonly storage;
|
|
@@ -26,21 +40,36 @@ export declare class GcsStorageDriver implements IStorageDriver {
|
|
|
26
40
|
private readonly prefix;
|
|
27
41
|
private readonly maxObjectBytes;
|
|
28
42
|
private readonly threshold;
|
|
43
|
+
private readonly readTimeoutMs;
|
|
44
|
+
private readonly clock;
|
|
29
45
|
constructor(options: GcsStorageDriverOptions);
|
|
30
46
|
capabilities(): StorageCaps;
|
|
31
47
|
private file;
|
|
32
|
-
/** The same object on the download client. */
|
|
48
|
+
/** The same object on the download client, off the SDK's shared agent ({@link downloadFile}). */
|
|
33
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;
|
|
34
52
|
putImmutable(key: GenKey, write: (sink: BlobSink) => Promise<void>): Promise<{
|
|
35
53
|
size: number;
|
|
36
54
|
sha256: string;
|
|
37
55
|
}>;
|
|
38
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;
|
|
39
65
|
getTail(key: GenKey, maxBytes: number): Promise<{
|
|
40
66
|
bytes: Uint8Array;
|
|
41
67
|
size: number;
|
|
42
68
|
}>;
|
|
43
|
-
/**
|
|
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
|
+
*/
|
|
44
73
|
private sizeOf;
|
|
45
74
|
/**
|
|
46
75
|
* The object's total size from a tail response, refused unless every header agrees with the bytes received. A 206
|
|
@@ -61,3 +90,4 @@ export declare class GcsStorageDriver implements IStorageDriver {
|
|
|
61
90
|
*/
|
|
62
91
|
private mapError;
|
|
63
92
|
}
|
|
93
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbitmaps/gcs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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.13.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^22.0.0",
|