[build-utils] Rename Lambda experimentalResponseStreaming prop to supportsResponseStreaming (#9721)

This commit is contained in:
Nathan Rajlich
2023-03-29 12:11:09 -07:00
committed by GitHub
parent 70c8b32cf0
commit 509926545e
5 changed files with 27 additions and 8 deletions

View File

@@ -23,6 +23,10 @@ export interface LambdaOptionsBase {
regions?: string[]; regions?: string[];
supportsMultiPayloads?: boolean; supportsMultiPayloads?: boolean;
supportsWrapper?: boolean; supportsWrapper?: boolean;
supportsResponseStreaming?: boolean;
/**
* @deprecated Use the `supportsResponseStreaming` property instead.
*/
experimentalResponseStreaming?: boolean; experimentalResponseStreaming?: boolean;
operationType?: string; operationType?: string;
framework?: FunctionFramework; framework?: FunctionFramework;
@@ -69,7 +73,7 @@ export class Lambda {
zipBuffer?: Buffer; zipBuffer?: Buffer;
supportsMultiPayloads?: boolean; supportsMultiPayloads?: boolean;
supportsWrapper?: boolean; supportsWrapper?: boolean;
experimentalResponseStreaming?: boolean; supportsResponseStreaming?: boolean;
framework?: FunctionFramework; framework?: FunctionFramework;
constructor(opts: LambdaOptions) { constructor(opts: LambdaOptions) {
@@ -83,6 +87,7 @@ export class Lambda {
regions, regions,
supportsMultiPayloads, supportsMultiPayloads,
supportsWrapper, supportsWrapper,
supportsResponseStreaming,
experimentalResponseStreaming, experimentalResponseStreaming,
operationType, operationType,
framework, framework,
@@ -162,7 +167,8 @@ export class Lambda {
this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined; this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
this.supportsMultiPayloads = supportsMultiPayloads; this.supportsMultiPayloads = supportsMultiPayloads;
this.supportsWrapper = supportsWrapper; this.supportsWrapper = supportsWrapper;
this.experimentalResponseStreaming = experimentalResponseStreaming; this.supportsResponseStreaming =
supportsResponseStreaming ?? experimentalResponseStreaming;
this.framework = framework; this.framework = framework;
} }
@@ -181,6 +187,16 @@ export class Lambda {
} }
return zipBuffer; return zipBuffer;
} }
/**
* @deprecated Use the `supportsResponseStreaming` property instead.
*/
get experimentalResponseStreaming(): boolean | undefined {
return this.supportsResponseStreaming;
}
set experimentalResponseStreaming(v: boolean | undefined) {
this.supportsResponseStreaming = v;
}
} }
const sema = new Sema(10); const sema = new Sema(10);

View File

@@ -795,7 +795,7 @@ export async function createLambdaFromPseudoLayers({
...lambdaOptions, ...lambdaOptions,
...(isStreaming ...(isStreaming
? { ? {
experimentalResponseStreaming: true, supportsResponseStreaming: true,
} }
: {}), : {}),
files, files,

View File

@@ -35,7 +35,7 @@ if (parseInt(process.versions.node.split('.')[0], 10) >= 16) {
expect(buildResult.output['api/hello-again']).toBeDefined(); expect(buildResult.output['api/hello-again']).toBeDefined();
expect(buildResult.output['api/hello-again'].type).toBe('Lambda'); expect(buildResult.output['api/hello-again'].type).toBe('Lambda');
expect( expect(
buildResult.output['api/hello-again'].experimentalResponseStreaming buildResult.output['api/hello-again'].supportsResponseStreaming
).toBe(true); ).toBe(true);
expect(buildResult.output['edge-route-handler']).toBeDefined(); expect(buildResult.output['edge-route-handler']).toBeDefined();

View File

@@ -487,8 +487,11 @@ export const build: BuildV3 = async ({
config.helpers === false || process.env.NODEJS_HELPERS === '0' config.helpers === false || process.env.NODEJS_HELPERS === '0'
); );
const experimentalResponseStreaming = const supportsResponseStreaming =
staticConfig?.experimentalResponseStreaming === true ? true : undefined; (staticConfig?.supportsResponseStreaming ??
staticConfig?.experimentalResponseStreaming) === true
? true
: undefined;
output = new NodejsLambda({ output = new NodejsLambda({
files: preparedFiles, files: preparedFiles,
@@ -497,7 +500,7 @@ export const build: BuildV3 = async ({
shouldAddHelpers, shouldAddHelpers,
shouldAddSourcemapSupport, shouldAddSourcemapSupport,
awsLambdaHandler, awsLambdaHandler,
experimentalResponseStreaming, supportsResponseStreaming,
}); });
} }

View File

@@ -522,7 +522,7 @@ async function createRenderNodeFunction(
shouldAddHelpers: false, shouldAddHelpers: false,
shouldAddSourcemapSupport: false, shouldAddSourcemapSupport: false,
operationType: 'SSR', operationType: 'SSR',
experimentalResponseStreaming: true, supportsResponseStreaming: true,
regions: config.regions, regions: config.regions,
memory: config.memory, memory: config.memory,
maxDuration: config.maxDuration, maxDuration: config.maxDuration,