@fastly/compute-js-static-publish 8.0.0-beta.11 → 8.0.0-beta.13
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/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +22 -4
- package/build/cli/cli/storage/s3-storage-provider.d.ts +3 -1
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/s3-storage-provider.js +18 -4
- package/build/cli/cli/storage/storage-provider.d.ts +2 -0
- package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/storage-provider.js +13 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AA+GA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAiiBhD"}
|
|
@@ -13,7 +13,7 @@ import { applyDefaults } from '../../util/data.js';
|
|
|
13
13
|
import { calculateFileSizeAndHash, enumerateFiles, rootRelative } from '../../util/files.js';
|
|
14
14
|
import { ensureVariantFileExists } from '../../util/variants.js';
|
|
15
15
|
import { concurrentMap } from '../../util/retryable.js';
|
|
16
|
-
import { loadStorageProviderFromStaticPublishRc, StorageProviderBatch, } from '../../storage/storage-provider.js';
|
|
16
|
+
import { getStorageKeysByHexPrefix, loadStorageProviderFromStaticPublishRc, StorageProviderBatch, } from '../../storage/storage-provider.js';
|
|
17
17
|
// Storage key format:
|
|
18
18
|
// <publishId>_index_<preview_id>.json
|
|
19
19
|
// <publishId>_settings_<preview_id>.json
|
|
@@ -79,6 +79,9 @@ S3 Storage Options (BETA):
|
|
|
79
79
|
If not set, the tool will check the S3_ACCESS_KEY_ID
|
|
80
80
|
and S3_SECRET_ACCESS_KEY environment variables.
|
|
81
81
|
|
|
82
|
+
--s3-upload-concurrency=<1-256> Number of objects to upload at the same time.
|
|
83
|
+
Default: 64
|
|
84
|
+
|
|
82
85
|
Global Options:
|
|
83
86
|
-h, --help Show this help message and exit.
|
|
84
87
|
|
|
@@ -105,6 +108,7 @@ export async function action(actionArgs) {
|
|
|
105
108
|
{ name: 'kv-overwrite', type: Boolean },
|
|
106
109
|
{ name: 's3-access-key-id', type: String, },
|
|
107
110
|
{ name: 's3-secret-access-key', type: String, },
|
|
111
|
+
{ name: 's3-upload-concurrency', type: String, },
|
|
108
112
|
];
|
|
109
113
|
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
110
114
|
if (parsed.needHelp) {
|
|
@@ -116,7 +120,17 @@ export async function action(actionArgs) {
|
|
|
116
120
|
help();
|
|
117
121
|
return;
|
|
118
122
|
}
|
|
119
|
-
const { verbose, config: configFilePathValue, ['collection-name']: collectionNameValue, ['root-dir']: rootDir, ['overwrite-existing']: _overwriteExisting, ['brotli-quality']: brotliQualityValue, ['expires-in']: expiresIn, ['expires-at']: expiresAt, ['expires-never']: expiresNever, local: localMode, ['fastly-api-token']: fastlyApiToken, ['kv-overwrite']: _kvOverwrite, ['s3-access-key-id']: s3AccessKeyId, ['s3-secret-access-key']: s3SecretAccessKey, } = parsed.commandLineOptions;
|
|
123
|
+
const { verbose, config: configFilePathValue, ['collection-name']: collectionNameValue, ['root-dir']: rootDir, ['overwrite-existing']: _overwriteExisting, ['brotli-quality']: brotliQualityValue, ['expires-in']: expiresIn, ['expires-at']: expiresAt, ['expires-never']: expiresNever, local: localMode, ['fastly-api-token']: fastlyApiToken, ['kv-overwrite']: _kvOverwrite, ['s3-access-key-id']: s3AccessKeyId, ['s3-secret-access-key']: s3SecretAccessKey, ['s3-upload-concurrency']: s3UploadConcurrencyValue, } = parsed.commandLineOptions;
|
|
124
|
+
let s3UploadConcurrency;
|
|
125
|
+
if (s3UploadConcurrencyValue !== undefined) {
|
|
126
|
+
if (typeof s3UploadConcurrencyValue !== 'string' || !/^\d+$/.test(s3UploadConcurrencyValue) ||
|
|
127
|
+
Number(s3UploadConcurrencyValue) < 1 || Number(s3UploadConcurrencyValue) > 256) {
|
|
128
|
+
console.error(`❌ --s3-upload-concurrency must be an integer from 1 to 256.`);
|
|
129
|
+
process.exitCode = 1;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
s3UploadConcurrency = Number(s3UploadConcurrencyValue);
|
|
133
|
+
}
|
|
120
134
|
const overwriteExisting = _overwriteExisting ?? _kvOverwrite;
|
|
121
135
|
// compute-js-static-publisher cli is always run from the Compute application directory
|
|
122
136
|
// in other words, the directory that contains `fastly.toml`.
|
|
@@ -201,6 +215,7 @@ export async function action(actionArgs) {
|
|
|
201
215
|
fastlyApiToken,
|
|
202
216
|
s3AccessKeyId,
|
|
203
217
|
s3SecretAccessKey,
|
|
218
|
+
s3UploadConcurrency,
|
|
204
219
|
});
|
|
205
220
|
}
|
|
206
221
|
catch (err) {
|
|
@@ -268,11 +283,14 @@ export async function action(actionArgs) {
|
|
|
268
283
|
// The key of a file is the hash of its content. If the key exists, storage
|
|
269
284
|
// already has the same content. Thus we do not compress, hash, or upload it again.
|
|
270
285
|
// In local mode, a key can refer to a working file that was deleted, so we do not list.
|
|
286
|
+
// All the keys that the scan looks for start with `<publishId>_files_sha256_` and a hex
|
|
287
|
+
// hash, so we list them in 16 parts at the same time.
|
|
271
288
|
let existingKeys;
|
|
272
289
|
if (!overwriteExisting && !localMode) {
|
|
273
290
|
console.log(`🔎 Listing files that are already in storage...`);
|
|
274
|
-
|
|
275
|
-
|
|
291
|
+
const listStart = Date.now();
|
|
292
|
+
existingKeys = new Set(await getStorageKeysByHexPrefix(storageProvider, `${publishId}_files_sha256_`) ?? []);
|
|
293
|
+
console.log(`✅ Found ${existingKeys.size} key(s) in ${((Date.now() - listStart) / 1000).toFixed(1)} s.`);
|
|
276
294
|
}
|
|
277
295
|
let existingVariantCount = 0;
|
|
278
296
|
function isVariantInStorage(variantKey, numChunks) {
|
|
@@ -2,9 +2,10 @@ import { S3Client } from '@aws-sdk/client-s3';
|
|
|
2
2
|
import { type Command, type HttpHandlerOptions } from '@aws-sdk/types';
|
|
3
3
|
import { type StorageEntry, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type ApplyBatchOptions } from './storage-provider.js';
|
|
4
4
|
type CommandOutput<C> = C extends Command<any, any, any, infer O, any> ? O : never;
|
|
5
|
+
export declare const DEFAULT_S3_UPLOAD_CONCURRENCY = 64;
|
|
5
6
|
export declare const buildStoreProvider: StorageProviderBuilder;
|
|
6
7
|
export declare class S3StorageProvider implements StorageProvider {
|
|
7
|
-
constructor(fastlyServiceId: string | undefined, fastlyApiToken: string | undefined, s3Region: string, accessKeyId: string, secretAccessKey: string, s3Bucket: string, s3Endpoint?: string);
|
|
8
|
+
constructor(fastlyServiceId: string | undefined, fastlyApiToken: string | undefined, s3Region: string, accessKeyId: string, secretAccessKey: string, s3Bucket: string, s3Endpoint?: string, uploadConcurrency?: number);
|
|
8
9
|
private readonly fastlyServiceId?;
|
|
9
10
|
private readonly fastlyApiContext?;
|
|
10
11
|
private readonly s3Region;
|
|
@@ -12,6 +13,7 @@ export declare class S3StorageProvider implements StorageProvider {
|
|
|
12
13
|
private readonly secretAccessKey;
|
|
13
14
|
private readonly s3Bucket;
|
|
14
15
|
private readonly s3Endpoint?;
|
|
16
|
+
private readonly uploadConcurrency;
|
|
15
17
|
private s3Client?;
|
|
16
18
|
getS3Client(): S3Client;
|
|
17
19
|
sendS3ClientCommand<C extends Command<any, any, any, any, any>>(command: C, options?: HttpHandlerOptions): Promise<CommandOutput<C>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/s3-storage-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"s3-storage-provider.d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AC,KAAK,EAAE,MAAM,GAAG,MAAM;IAInC,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA4B7D"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
5
|
import fs from 'node:fs';
|
|
6
|
+
import http from 'node:http';
|
|
7
|
+
import https from 'node:https';
|
|
6
8
|
import path from 'node:path';
|
|
7
9
|
import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client, S3ServiceException, paginateListObjectsV2, } from '@aws-sdk/client-s3';
|
|
8
10
|
import { isS3StorageConfigRc, } from '../../models/config/static-publish-rc.js';
|
|
@@ -14,6 +16,10 @@ import { rootRelative, } from '../util/files.js';
|
|
|
14
16
|
import { loadApiToken, } from '../util/api-token.js';
|
|
15
17
|
import { readServiceId, } from '../util/fastly-toml.js';
|
|
16
18
|
import { purgeSurrogateKey, } from '../util/purge.js';
|
|
19
|
+
// The number of objects to upload at the same time. S3 accepts many parallel
|
|
20
|
+
// requests, and each request mostly waits for the network. In a test with small
|
|
21
|
+
// objects, 64 was approximately 4 times faster than 12.
|
|
22
|
+
export const DEFAULT_S3_UPLOAD_CONCURRENCY = 64;
|
|
17
23
|
export const buildStoreProvider = async (config, context) => {
|
|
18
24
|
if (isS3StorageConfigRc(config)) {
|
|
19
25
|
console.log(` Working on S3 (or compatible) storage (BETA)...`);
|
|
@@ -49,10 +55,11 @@ export const buildStoreProvider = async (config, context) => {
|
|
|
49
55
|
console.log(`✔️ Fastly API Token: ${apiTokenResult.apiToken.slice(0, 4)}${'*'.repeat(apiTokenResult.apiToken.length - 4)} from '${apiTokenResult.source}'`);
|
|
50
56
|
apiToken = apiTokenResult.apiToken;
|
|
51
57
|
}
|
|
52
|
-
return new S3StorageProvider(serviceId, apiToken, region, s3CredentialsResult.s3AccessKeyId, s3CredentialsResult.s3SecretAccessKey, bucket, endpoint);
|
|
58
|
+
return new S3StorageProvider(serviceId, apiToken, region, s3CredentialsResult.s3AccessKeyId, s3CredentialsResult.s3SecretAccessKey, bucket, endpoint, context.s3UploadConcurrency ?? DEFAULT_S3_UPLOAD_CONCURRENCY);
|
|
53
59
|
};
|
|
54
60
|
export class S3StorageProvider {
|
|
55
|
-
constructor(fastlyServiceId, fastlyApiToken, s3Region, accessKeyId, secretAccessKey, s3Bucket, s3Endpoint) {
|
|
61
|
+
constructor(fastlyServiceId, fastlyApiToken, s3Region, accessKeyId, secretAccessKey, s3Bucket, s3Endpoint, uploadConcurrency = DEFAULT_S3_UPLOAD_CONCURRENCY) {
|
|
62
|
+
this.uploadConcurrency = uploadConcurrency;
|
|
56
63
|
this.fastlyServiceId = fastlyServiceId;
|
|
57
64
|
this.fastlyApiContext = fastlyApiToken != null ? { apiToken: fastlyApiToken } : undefined;
|
|
58
65
|
this.s3Region = s3Region;
|
|
@@ -65,7 +72,14 @@ export class S3StorageProvider {
|
|
|
65
72
|
if (this.s3Client != null) {
|
|
66
73
|
return this.s3Client;
|
|
67
74
|
}
|
|
75
|
+
// The SDK default is 50 sockets. Use at least one socket for each
|
|
76
|
+
// concurrent upload, so that uploads do not wait for a socket.
|
|
77
|
+
const maxSockets = Math.max(50, this.uploadConcurrency);
|
|
68
78
|
this.s3Client = new S3Client({
|
|
79
|
+
requestHandler: {
|
|
80
|
+
httpAgent: new http.Agent({ keepAlive: true, maxSockets }),
|
|
81
|
+
httpsAgent: new https.Agent({ keepAlive: true, maxSockets }),
|
|
82
|
+
},
|
|
69
83
|
region: this.s3Region,
|
|
70
84
|
endpoint: this.s3Endpoint,
|
|
71
85
|
forcePathStyle: this.s3Endpoint != null,
|
|
@@ -184,14 +198,14 @@ export class S3StorageProvider {
|
|
|
184
198
|
if (existingKeys != null) {
|
|
185
199
|
toWrite = entriesToUpload(toWrite, existingKeys);
|
|
186
200
|
}
|
|
187
|
-
console.log(`📤 Uploading entries to S3 storage.`);
|
|
201
|
+
console.log(`📤 Uploading ${toWrite.length} entries to S3 storage (${this.uploadConcurrency} at a time).`);
|
|
188
202
|
// fastlyApiContext is non-null if useKvStore is true
|
|
189
203
|
await this.doConcurrentParallel(toWrite, async ({ filePath, metadataJson }, key) => {
|
|
190
204
|
// const fileStream = fs.createReadStream(filePath);
|
|
191
205
|
const fileData = fs.readFileSync(filePath);
|
|
192
206
|
await this.submitStorageEntry(key, filePath, fileData, metadataJson);
|
|
193
207
|
console.log(` 🌐 Submitted asset "${rootRelative(filePath)}" to S3 storage with key "${key}".`);
|
|
194
|
-
},
|
|
208
|
+
}, this.uploadConcurrency, true);
|
|
195
209
|
console.log(`✅ Uploaded entries to S3 storage.`);
|
|
196
210
|
}
|
|
197
211
|
async doConcurrentParallel(objects, fn, maxConcurrent = 12, throwOnError = false) {
|
|
@@ -37,8 +37,10 @@ export type StorageProviderBuilderContext = {
|
|
|
37
37
|
fastlyApiToken?: string;
|
|
38
38
|
s3AccessKeyId?: string;
|
|
39
39
|
s3SecretAccessKey?: string;
|
|
40
|
+
s3UploadConcurrency?: number;
|
|
40
41
|
};
|
|
41
42
|
export type StorageProviderBuilder = (config: StaticPublishRc, context: StorageProviderBuilderContext) => (Promise<StorageProvider | null> | StorageProvider | null);
|
|
43
|
+
export declare function getStorageKeysByHexPrefix(storageProvider: StorageProvider, prefix: string): Promise<string[] | null>;
|
|
42
44
|
export declare function registerStorageProviderBuilder(builder: StorageProviderBuilder): void;
|
|
43
45
|
export declare function loadStorageProviderFromStaticPublishRc(config: StaticPublishRc, context: StorageProviderBuilderContext): Promise<StorageProvider>;
|
|
44
46
|
//# sourceMappingURL=storage-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/storage-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,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AAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAG9B,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B,CAAC;AAEF,qBAAa,oBAAoB;;IAI/B,2BAA2B,EAAE,yBAAyB,EAAE,CAAC;IACzD,GAAG,CAAC,KAAK,EAAE,yBAAyB;CAGrC;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AACF,MAAM,MAAM,sBAAsB,GAChC,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,6BAA6B,KAAK,CAAC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,eAAe,GAAG,IAAI,CAAC,CAAC;AAQlI,wBAAsB,yBAAyB,CAAC,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAQ1H;AAGD,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,sBAAsB,QAE7E;AAED,wBAAsB,sCAAsC,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,6BAA6B,4BAS3H"}
|
|
@@ -10,6 +10,19 @@ export class StorageProviderBatch {
|
|
|
10
10
|
this.storageProviderBatchEntries.push(entry);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
// Lists the keys that start with `prefix` followed by a lowercase hex digit.
|
|
14
|
+
// Use it for a prefix that a hex hash follows, such as `<publishId>_files_sha256_`.
|
|
15
|
+
// A listing gets its keys one page at a time, and each page needs the previous
|
|
16
|
+
// page. Thus this function runs one listing for each of the 16 hex digits at the
|
|
17
|
+
// same time. The total time is approximately the time of the largest part.
|
|
18
|
+
// Returns null only if all the listings return null.
|
|
19
|
+
export async function getStorageKeysByHexPrefix(storageProvider, prefix) {
|
|
20
|
+
const parts = await Promise.all('0123456789abcdef'.split('').map((digit) => storageProvider.getStorageKeys(prefix + digit)));
|
|
21
|
+
if (parts.every((part) => part == null)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return parts.flatMap((part) => part ?? []);
|
|
25
|
+
}
|
|
13
26
|
const _storageProviderBuilders = [];
|
|
14
27
|
export function registerStorageProviderBuilder(builder) {
|
|
15
28
|
_storageProviderBuilders.push(builder);
|
package/package.json
CHANGED