@kensio/yulin 1.21.8 → 1.21.9
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/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-properties.js +2 -0
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-property-rules.js +1 -1
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.d.ts +2 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.js +4 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-refusals.js +0 -5
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.d.ts +2 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.js +2 -0
- package/dist/service/lambda/command/event-source-mapping/sim-lambda-event-source-mapping-commands.d.ts +2 -0
- package/dist/service/lambda/destination/sim-lambda-destination-targets.d.ts +2 -1
- package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.d.ts +0 -4
- package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.js +10 -15
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.d.ts +1 -6
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.js +9 -27
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.d.ts +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.js +27 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.d.ts +1 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.js +3 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.d.ts +13 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.js +27 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.js +26 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.d.ts +1 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.js +7 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.d.ts +17 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.js +12 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.js +28 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.d.ts +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.js +23 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.d.ts +3 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.js +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.js +38 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.d.ts +41 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.js +17 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.d.ts +21 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.js +39 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.d.ts +7 -37
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.js +22 -62
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.d.ts +4 -39
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.js +12 -64
- package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.d.ts +10 -3
- package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.js +12 -3
- package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.d.ts +7 -0
- package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.js +38 -0
- package/dist/service/lambda/event-source/stream/kinesis/sim-kinesis-event-source-streams.js +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-reader.js +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.d.ts +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.js +7 -0
- package/dist/service/lambda/event-source/stream/sim-lambda-event-source-streams.d.ts +1 -0
- package/dist/service/lambda/index.d.ts +1 -0
- package/dist/service/lambda/sim-lambda-commands.js +1 -0
- package/docs/services/lambda/README.md +59 -6
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { simLambdaStreamDestinationConfig } from "../../event-source/sim-lambda-stream-destination-config.js";
|
|
1
2
|
import { SimCfnLambdaPropertyParser } from "../function/sim-cfn-lambda-property-parser.js";
|
|
2
3
|
import { assertSimulatedEventSourceMappingProperties } from "./sim-cfn-lambda-event-source-mapping-property-rules.js";
|
|
3
4
|
import { simCfnLambdaTargetFunctionName } from "../function/sim-cfn-lambda-target-function.js";
|
|
@@ -34,6 +35,7 @@ export class SimCfnLambdaEventSourceMappingProperties {
|
|
|
34
35
|
assertSimulatedEventSourceMappingProperties(this.resource, this.properties);
|
|
35
36
|
return {
|
|
36
37
|
EventSourceArn: eventSourceArn,
|
|
38
|
+
DestinationConfig: simLambdaStreamDestinationConfig(this.properties["DestinationConfig"]),
|
|
37
39
|
FunctionName: simCfnLambdaTargetFunctionName(this.parser.requiredString(this.resource, this.properties["FunctionName"], "FunctionName")),
|
|
38
40
|
BatchSize: this.parser.optionalNumber(this.resource, this.properties["BatchSize"], "BatchSize"),
|
|
39
41
|
Enabled: this.parser.optionalBoolean(this.resource, this.properties["Enabled"], "Enabled"),
|
|
@@ -18,6 +18,7 @@ const simulatedPropertyNames = new Set([
|
|
|
18
18
|
"MaximumBatchingWindowInSeconds",
|
|
19
19
|
"MaximumRecordAgeInSeconds",
|
|
20
20
|
"MaximumRetryAttempts",
|
|
21
|
+
"DestinationConfig",
|
|
21
22
|
"StartingPosition",
|
|
22
23
|
"StartingPositionTimestamp",
|
|
23
24
|
]);
|
|
@@ -32,7 +33,6 @@ const simulatedPropertyNames = new Set([
|
|
|
32
33
|
const unsimulatedPropertyNames = new Set([
|
|
33
34
|
"AmazonManagedKafkaEventSourceConfig",
|
|
34
35
|
"BisectBatchOnFunctionError",
|
|
35
|
-
"DestinationConfig",
|
|
36
36
|
"DocumentDBEventSourceConfig",
|
|
37
37
|
"FilterCriteria",
|
|
38
38
|
"KmsKeyArn",
|
package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SimLambdaStreamDestinationConfiguration } from "../../event-source/sim-lambda-stream-destination-config.js";
|
|
1
2
|
import type { SimAwsAccountRegionScope } from "../../../aws/sim-aws-account-region-scope.js";
|
|
2
3
|
import { type SimLambdaEventSourceArn } from "../../event-source/sim-lambda-event-source-arn.js";
|
|
3
4
|
import type { SimLambdaFunctionResponseType } from "../../event-source/sim-lambda-event-source-mapping.js";
|
|
@@ -29,6 +30,7 @@ export declare class SimLambdaEventSourceMappingInput {
|
|
|
29
30
|
readonly start: SimLambdaEventSourceStart | undefined;
|
|
30
31
|
readonly enabled: boolean;
|
|
31
32
|
readonly functionResponseTypes: readonly SimLambdaFunctionResponseType[];
|
|
33
|
+
readonly destinationConfig: SimLambdaStreamDestinationConfiguration | undefined;
|
|
32
34
|
/**
|
|
33
35
|
* When a failed batch stops being delivered again, for a source that leaves
|
|
34
36
|
* the counting to the mapping.
|
package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { simLambdaStreamDestinationConfig, } from "../../event-source/sim-lambda-stream-destination-config.js";
|
|
1
2
|
import { simLambdaEventSourceArnOf, } from "../../event-source/sim-lambda-event-source-arn.js";
|
|
2
3
|
import { SimLambdaInvalidParameterValueException } from "../../error/sim-lambda.error.js";
|
|
3
4
|
import { simLambdaFunctionReferenceOf } from "../../function/sim-lambda-function-reference.js";
|
|
@@ -28,6 +29,7 @@ export class SimLambdaEventSourceMappingInput {
|
|
|
28
29
|
start;
|
|
29
30
|
enabled;
|
|
30
31
|
functionResponseTypes;
|
|
32
|
+
destinationConfig;
|
|
31
33
|
/**
|
|
32
34
|
* When a failed batch stops being delivered again, for a source that leaves
|
|
33
35
|
* the counting to the mapping.
|
|
@@ -41,6 +43,7 @@ export class SimLambdaEventSourceMappingInput {
|
|
|
41
43
|
this.start = properties.start;
|
|
42
44
|
this.enabled = properties.enabled;
|
|
43
45
|
this.functionResponseTypes = properties.functionResponseTypes;
|
|
46
|
+
this.destinationConfig = properties.destinationConfig;
|
|
44
47
|
this.streamRetryLimits = properties.streamRetryLimits;
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
@@ -53,6 +56,7 @@ export class SimLambdaEventSourceMappingInput {
|
|
|
53
56
|
refuseUnsimulatedInput(input);
|
|
54
57
|
return new this({
|
|
55
58
|
eventSourceArn,
|
|
59
|
+
destinationConfig: simLambdaStreamDestinationConfig(input.DestinationConfig, eventSourceArn.kind),
|
|
56
60
|
...simLambdaFunctionReferenceOf(requiredString(input.FunctionName, "functionName")),
|
|
57
61
|
batchSize: eventSourceArn.batchRules.sizeIn(input.BatchSize),
|
|
58
62
|
start: eventSourceArn.startingPositionRules.startIn({
|
package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-refusals.js
CHANGED
|
@@ -12,11 +12,6 @@ const unsimulatedInputs = new Map([
|
|
|
12
12
|
["FilterCriteria", "event filtering is not simulated"],
|
|
13
13
|
["ScalingConfig", "polling concurrency is not simulated"],
|
|
14
14
|
["ProvisionedPollerConfig", "polling concurrency is not simulated"],
|
|
15
|
-
[
|
|
16
|
-
"DestinationConfig",
|
|
17
|
-
"failure destinations are not simulated, so a stream batch that runs out " +
|
|
18
|
-
"of attempts is discarded rather than sent anywhere",
|
|
19
|
-
],
|
|
20
15
|
[
|
|
21
16
|
"BisectBatchOnFunctionError",
|
|
22
17
|
"batch bisection is not simulated, so a failing stream batch is retried " +
|
package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SimLambdaDestinationTargets } from "../../destination/sim-lambda-destination-targets.js";
|
|
1
2
|
import type { CommandHandler } from "../../../../command/command-handler.js";
|
|
2
3
|
import type { BackgroundScheduler } from "../../../../util/background/background.js";
|
|
3
4
|
import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
|
|
@@ -19,6 +20,7 @@ interface CreateEventSourceMappingCommandHandlerProperties {
|
|
|
19
20
|
readonly kinesisStreams: SimLambdaKinesisStreams;
|
|
20
21
|
readonly functions: SimLambdaFunctionLookup;
|
|
21
22
|
readonly iam: SimIamInterServiceAuthZ;
|
|
23
|
+
readonly destinations?: SimLambdaDestinationTargets;
|
|
22
24
|
readonly background: BackgroundScheduler;
|
|
23
25
|
}
|
|
24
26
|
interface CreateEventSourceMappingCommandHandlerOptions {
|
package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.js
CHANGED
|
@@ -81,6 +81,8 @@ export class CreateEventSourceMappingCommandHandler {
|
|
|
81
81
|
enabled: input.enabled,
|
|
82
82
|
functionResponseTypes: input.functionResponseTypes,
|
|
83
83
|
streamRetryLimits: input.streamRetryLimits,
|
|
84
|
+
destinationConfig: input.destinationConfig,
|
|
85
|
+
destinations: this.properties.destinations,
|
|
84
86
|
createdAt: this.properties.background.now(),
|
|
85
87
|
});
|
|
86
88
|
this.properties.mappings.add(mapping);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SimLambdaDestinationTargets } from "../../destination/sim-lambda-destination-targets.js";
|
|
1
2
|
import type { BackgroundScheduler } from "../../../../util/background/background.js";
|
|
2
3
|
import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
|
|
3
4
|
import type { SimAwsAccountRegionScope } from "../../../aws/sim-aws-account-region-scope.js";
|
|
@@ -17,6 +18,7 @@ interface SimLambdaEventSourceMappingCommandsProperties {
|
|
|
17
18
|
readonly kinesisStreams: SimLambdaKinesisStreams;
|
|
18
19
|
readonly functions: SimLambdaFunctionLookup;
|
|
19
20
|
readonly iam: SimIamInterServiceAuthZ;
|
|
21
|
+
readonly destinations?: SimLambdaDestinationTargets;
|
|
20
22
|
readonly background: BackgroundScheduler;
|
|
21
23
|
}
|
|
22
24
|
interface SimLambdaEventSourceMappingCommandOptions {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SimLambdaStreamFailureRecord } from "../event-source/poll/sim-lambda-stream-failure-record.js";
|
|
1
2
|
import type { SimLambdaDestinationArn } from "./sim-lambda-destination-arn.js";
|
|
2
3
|
import type { SimLambdaDestinationRecord } from "./sim-lambda-destination-record.js";
|
|
3
4
|
/**
|
|
@@ -5,7 +6,7 @@ import type { SimLambdaDestinationRecord } from "./sim-lambda-destination-record
|
|
|
5
6
|
*/
|
|
6
7
|
export interface SimLambdaDestinationDeliveryRequest {
|
|
7
8
|
readonly destinationArn: SimLambdaDestinationArn;
|
|
8
|
-
readonly record: SimLambdaDestinationRecord;
|
|
9
|
+
readonly record: SimLambdaDestinationRecord | SimLambdaStreamFailureRecord;
|
|
9
10
|
/**
|
|
10
11
|
* The function whose invocation produced this record, which is what the
|
|
11
12
|
* delivery is attributed to.
|
|
@@ -49,9 +49,5 @@ export declare class SimLambdaKinesisShardPoller implements SimLambdaEventSource
|
|
|
49
49
|
* reading the same records.
|
|
50
50
|
*/
|
|
51
51
|
poll(): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* The function this mapping delivers to, while it should be delivering.
|
|
54
|
-
*/
|
|
55
|
-
private pollingFunction;
|
|
56
52
|
}
|
|
57
53
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { processSimLambdaStreamBatch } from "../sim-lambda-stream-batch-processing.js";
|
|
2
|
+
import { simLambdaKinesisStreamRecordTimes } from "../sim-lambda-stream-record-times.js";
|
|
1
3
|
import { simLambdaEventSourceFunction } from "../sim-lambda-event-source-function.js";
|
|
2
4
|
import { SimLambdaEventSourcePollTurn, } from "../sim-lambda-event-source-poll-turn.js";
|
|
3
5
|
import { SimLambdaStreamProgress } from "../sim-lambda-stream-progress.js";
|
|
@@ -57,7 +59,7 @@ export class SimLambdaKinesisShardPoller {
|
|
|
57
59
|
* reading the same records.
|
|
58
60
|
*/
|
|
59
61
|
async poll() {
|
|
60
|
-
const simFunction = this.
|
|
62
|
+
const simFunction = simLambdaEventSourceFunction(this.functions, this.mapping, this.stopped);
|
|
61
63
|
if (simFunction === undefined) {
|
|
62
64
|
return;
|
|
63
65
|
}
|
|
@@ -65,19 +67,12 @@ export class SimLambdaKinesisShardPoller {
|
|
|
65
67
|
// Reading is done as the function's execution role, as on real Lambda, so
|
|
66
68
|
// simulated IAM decides whether this mapping may read its stream.
|
|
67
69
|
const batch = await this.shard.read(progress.position, this.mapping.batchSize);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* The function this mapping delivers to, while it should be delivering.
|
|
76
|
-
*/
|
|
77
|
-
pollingFunction() {
|
|
78
|
-
if (this.stopped || !this.mapping.isPolling) {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
return simLambdaEventSourceFunction(this.functions, this.mapping);
|
|
70
|
+
await processSimLambdaStreamBatch({
|
|
71
|
+
batch,
|
|
72
|
+
progress,
|
|
73
|
+
simFunction,
|
|
74
|
+
times: simLambdaKinesisStreamRecordTimes,
|
|
75
|
+
deliver: async (records) => await this.delivery.to(simFunction, records),
|
|
76
|
+
});
|
|
82
77
|
}
|
|
83
78
|
}
|
package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.d.ts
CHANGED
|
@@ -26,10 +26,9 @@ interface SimLambdaDynamoDbStreamEventSourcePollerProperties {
|
|
|
26
26
|
* overlapping the first would hand the same records to the function twice.
|
|
27
27
|
*/
|
|
28
28
|
export declare class SimLambdaDynamoDbStreamEventSourcePoller implements SimLambdaEventSourcePoller, SimLambdaEventSourcePolls {
|
|
29
|
-
private readonly mapping;
|
|
30
|
-
private readonly functions;
|
|
31
29
|
private readonly stream;
|
|
32
30
|
private readonly delivery;
|
|
31
|
+
private readonly polling;
|
|
33
32
|
private readonly progress;
|
|
34
33
|
private readonly turn;
|
|
35
34
|
private stopped;
|
|
@@ -68,9 +67,5 @@ export declare class SimLambdaDynamoDbStreamEventSourcePoller implements SimLamb
|
|
|
68
67
|
* reading the same records.
|
|
69
68
|
*/
|
|
70
69
|
poll(): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* The function this mapping delivers to, while it should be delivering.
|
|
73
|
-
*/
|
|
74
|
-
private pollingFunction;
|
|
75
70
|
}
|
|
76
71
|
export {};
|
package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SimLambdaDynamoDbStreamPolling } from "./sim-lambda-dynamodb-stream-polling.js";
|
|
2
2
|
import { SimLambdaDynamoDbPolledStream } from "./sim-lambda-dynamodb-polled-stream.js";
|
|
3
3
|
import { SimLambdaDynamoDbStreamDelivery } from "./sim-lambda-dynamodb-stream-delivery.js";
|
|
4
4
|
import { SimLambdaEventSourcePollTurn, } from "./sim-lambda-event-source-poll-turn.js";
|
|
@@ -17,17 +17,14 @@ import { SimLambdaStreamProgress } from "./sim-lambda-stream-progress.js";
|
|
|
17
17
|
* overlapping the first would hand the same records to the function twice.
|
|
18
18
|
*/
|
|
19
19
|
export class SimLambdaDynamoDbStreamEventSourcePoller {
|
|
20
|
-
mapping;
|
|
21
|
-
functions;
|
|
22
20
|
stream;
|
|
23
21
|
delivery;
|
|
22
|
+
polling;
|
|
24
23
|
progress;
|
|
25
24
|
turn = new SimLambdaEventSourcePollTurn(this);
|
|
26
25
|
stopped = false;
|
|
27
26
|
constructor(properties) {
|
|
28
27
|
const { eventSourceArn, mapping } = properties;
|
|
29
|
-
this.mapping = mapping;
|
|
30
|
-
this.functions = properties.functions;
|
|
31
28
|
this.stream = new SimLambdaDynamoDbPolledStream(properties.streams, eventSourceArn.value);
|
|
32
29
|
this.delivery = new SimLambdaDynamoDbStreamDelivery({
|
|
33
30
|
mapping,
|
|
@@ -40,6 +37,12 @@ export class SimLambdaDynamoDbStreamEventSourcePoller {
|
|
|
40
37
|
await this.turn.take();
|
|
41
38
|
},
|
|
42
39
|
});
|
|
40
|
+
this.polling = new SimLambdaDynamoDbStreamPolling({
|
|
41
|
+
...properties,
|
|
42
|
+
stream: this.stream,
|
|
43
|
+
progress: this.progress,
|
|
44
|
+
delivery: this.delivery,
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Watch the stream this mapping polls.
|
|
@@ -88,27 +91,6 @@ export class SimLambdaDynamoDbStreamEventSourcePoller {
|
|
|
88
91
|
* reading the same records.
|
|
89
92
|
*/
|
|
90
93
|
async poll() {
|
|
91
|
-
|
|
92
|
-
if (simFunction === undefined) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const { progress } = this;
|
|
96
|
-
// Reading is done as the function's execution role, as on real Lambda, so
|
|
97
|
-
// simulated IAM decides whether this mapping may read its stream.
|
|
98
|
-
const batch = await this.stream.read(simFunction.roleArn, progress.position, this.mapping.batchSize);
|
|
99
|
-
if (batch.records.length === 0) {
|
|
100
|
-
progress.caughtUp(batch);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
progress.after(await this.delivery.to(simFunction, batch.records), batch);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* The function this mapping delivers to, while it should be delivering.
|
|
107
|
-
*/
|
|
108
|
-
pollingFunction() {
|
|
109
|
-
if (this.stopped || !this.mapping.isPolling) {
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
return simLambdaEventSourceFunction(this.functions, this.mapping);
|
|
94
|
+
await this.polling.poll(this.stopped);
|
|
113
95
|
}
|
|
114
96
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SimLambdaFunctionLookup } from "../../function/url/sim-lambda-function-lookup.js";
|
|
2
|
+
import type { SimLambdaEventSourceMapping } from "../sim-lambda-event-source-mapping.js";
|
|
3
|
+
import type { SimLambdaDynamoDbPolledStream } from "./sim-lambda-dynamodb-polled-stream.js";
|
|
4
|
+
import type { SimLambdaDynamoDbStreamDelivery } from "./sim-lambda-dynamodb-stream-delivery.js";
|
|
5
|
+
import type { SimLambdaStreamProgress } from "./sim-lambda-stream-progress.js";
|
|
6
|
+
interface DynamoDbStreamPollingProperties {
|
|
7
|
+
readonly functions: SimLambdaFunctionLookup;
|
|
8
|
+
readonly mapping: SimLambdaEventSourceMapping;
|
|
9
|
+
readonly stream: SimLambdaDynamoDbPolledStream;
|
|
10
|
+
readonly delivery: SimLambdaDynamoDbStreamDelivery;
|
|
11
|
+
readonly progress: SimLambdaStreamProgress;
|
|
12
|
+
}
|
|
13
|
+
/** Read and process DynamoDB batches as the function execution role. */
|
|
14
|
+
export declare class SimLambdaDynamoDbStreamPolling {
|
|
15
|
+
private readonly properties;
|
|
16
|
+
constructor(properties: DynamoDbStreamPollingProperties);
|
|
17
|
+
poll(stopped: boolean): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { simLambdaDynamoDbStreamRecordTimes } from "./sim-lambda-stream-record-times.js";
|
|
2
|
+
import { processSimLambdaStreamBatch } from "./sim-lambda-stream-batch-processing.js";
|
|
3
|
+
import { simLambdaEventSourceFunction } from "./sim-lambda-event-source-function.js";
|
|
4
|
+
/** Read and process DynamoDB batches as the function execution role. */
|
|
5
|
+
export class SimLambdaDynamoDbStreamPolling {
|
|
6
|
+
properties;
|
|
7
|
+
constructor(properties) {
|
|
8
|
+
this.properties = properties;
|
|
9
|
+
}
|
|
10
|
+
async poll(stopped) {
|
|
11
|
+
const simFunction = simLambdaEventSourceFunction(this.properties.functions, this.properties.mapping, stopped);
|
|
12
|
+
if (simFunction === undefined) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { progress, stream, mapping, delivery } = this.properties;
|
|
16
|
+
// Reading is done as the function's execution role, as on real Lambda, so
|
|
17
|
+
// simulated IAM decides whether this mapping may read its stream.
|
|
18
|
+
const batch = await stream.read(simFunction.roleArn, progress.position, mapping.batchSize);
|
|
19
|
+
await processSimLambdaStreamBatch({
|
|
20
|
+
batch,
|
|
21
|
+
progress,
|
|
22
|
+
simFunction,
|
|
23
|
+
times: simLambdaDynamoDbStreamRecordTimes,
|
|
24
|
+
deliver: async (records) => await delivery.to(simFunction, records),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -9,4 +9,4 @@ import type { SimLambdaEventSourceMapping } from "../sim-lambda-event-source-map
|
|
|
9
9
|
* delivers to. A function that has gone, and a qualifier that names nothing,
|
|
10
10
|
* both answer with nothing, and the poll then does nothing.
|
|
11
11
|
*/
|
|
12
|
-
export declare function simLambdaEventSourceFunction(functions: SimLambdaFunctionLookup, mapping: SimLambdaEventSourceMapping): SimLambdaFunction | undefined;
|
|
12
|
+
export declare function simLambdaEventSourceFunction(functions: SimLambdaFunctionLookup, mapping: SimLambdaEventSourceMapping, stopped?: boolean): SimLambdaFunction | undefined;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* delivers to. A function that has gone, and a qualifier that names nothing,
|
|
7
7
|
* both answer with nothing, and the poll then does nothing.
|
|
8
8
|
*/
|
|
9
|
-
export function simLambdaEventSourceFunction(functions, mapping) {
|
|
9
|
+
export function simLambdaEventSourceFunction(functions, mapping, stopped = false) {
|
|
10
|
+
if (stopped || !mapping.isPolling)
|
|
11
|
+
return undefined;
|
|
10
12
|
return functions.findTarget(mapping.functionName, mapping.qualifier)
|
|
11
13
|
?.simFunction;
|
|
12
14
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SimClock } from "../../../../util/clock/sim-clock.js";
|
|
2
|
+
import type { SimLambdaStreamRetryLimits } from "../sim-lambda-stream-retry-limits.js";
|
|
3
|
+
import type { SimLambdaEventSourceStreamPosition } from "../stream/sim-lambda-event-source-streams.js";
|
|
4
|
+
import type { SimLambdaStreamDiscard } from "./sim-lambda-stream-failure-record.js";
|
|
5
|
+
import type { SimLambdaStreamRecordTime } from "./sim-lambda-stream-record-times.js";
|
|
6
|
+
/** Identifies the expired prefix at the time a batch is polled. */
|
|
7
|
+
export declare class SimLambdaStreamBatchAge {
|
|
8
|
+
private readonly limits;
|
|
9
|
+
private readonly clock;
|
|
10
|
+
constructor(limits: SimLambdaStreamRetryLimits, clock: SimClock);
|
|
11
|
+
discarded(records: readonly SimLambdaStreamRecordTime[]): SimLambdaStreamDiscard | undefined;
|
|
12
|
+
firstLivePosition(records: readonly SimLambdaStreamRecordTime[], count: number): SimLambdaEventSourceStreamPosition;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { assertDefined } from "../../../../util/type-guard/defined.js";
|
|
2
|
+
/** Identifies the expired prefix at the time a batch is polled. */
|
|
3
|
+
export class SimLambdaStreamBatchAge {
|
|
4
|
+
limits;
|
|
5
|
+
clock;
|
|
6
|
+
constructor(limits, clock) {
|
|
7
|
+
this.limits = limits;
|
|
8
|
+
this.clock = clock;
|
|
9
|
+
}
|
|
10
|
+
discarded(records) {
|
|
11
|
+
const at = this.clock.now();
|
|
12
|
+
const firstLive = records.findIndex((record) => !this.limits.hasAgedOut(record.at, at));
|
|
13
|
+
const count = firstLive === -1 ? records.length : firstLive;
|
|
14
|
+
if (count === 0)
|
|
15
|
+
return undefined;
|
|
16
|
+
return {
|
|
17
|
+
records: records.slice(0, count),
|
|
18
|
+
condition: "RecordAgeExceeded",
|
|
19
|
+
at,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
firstLivePosition(records, count) {
|
|
23
|
+
const sequenceNumber = records.at(count)?.sequenceNumber;
|
|
24
|
+
assertDefined(sequenceNumber, "live stream record sequence number");
|
|
25
|
+
return { kind: "sequence", sequenceNumber };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SimLambdaStreamFailureRecord } from "./sim-lambda-stream-failure-record.js";
|
|
2
|
+
import type { SimLambdaStreamRecordTime } from "./sim-lambda-stream-record-times.js";
|
|
3
|
+
export interface SimLambdaStreamBatchInfo {
|
|
4
|
+
readonly shardId: string;
|
|
5
|
+
readonly streamArn: string;
|
|
6
|
+
readonly startSequenceNumber: string;
|
|
7
|
+
readonly endSequenceNumber: string;
|
|
8
|
+
readonly approximateArrivalOfFirstRecord: string;
|
|
9
|
+
readonly approximateArrivalOfLastRecord: string;
|
|
10
|
+
readonly batchSize: number;
|
|
11
|
+
}
|
|
12
|
+
/** Identify the discarded records by shard and sequence-number bounds. */
|
|
13
|
+
export declare function simLambdaStreamBatchInfo(records: readonly SimLambdaStreamRecordTime[], streamArn: string, shardId: string | undefined): SimLambdaStreamBatchInfo;
|
|
14
|
+
/** Identify the discarded records by shard and sequence-number bounds. */
|
|
15
|
+
export declare function streamFailureBatchInfo(arn: string, info: SimLambdaStreamBatchInfo): Pick<SimLambdaStreamFailureRecord, "DDBStreamBatchInfo" | "KinesisBatchInfo">;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { assertDefined } from "../../../../util/type-guard/defined.js";
|
|
2
|
+
/** Identify the discarded records by shard and sequence-number bounds. */
|
|
3
|
+
export function simLambdaStreamBatchInfo(records, streamArn, shardId) {
|
|
4
|
+
const first = records.at(0);
|
|
5
|
+
const last = records.at(-1);
|
|
6
|
+
assertDefined(shardId, "discarded stream batch shard ID");
|
|
7
|
+
assertDefined(first?.sequenceNumber, "discarded batch start sequence number");
|
|
8
|
+
assertDefined(last?.sequenceNumber, "discarded batch end sequence number");
|
|
9
|
+
assertDefined(first.at, "discarded batch first arrival time");
|
|
10
|
+
assertDefined(last.at, "discarded batch last arrival time");
|
|
11
|
+
return {
|
|
12
|
+
shardId,
|
|
13
|
+
streamArn,
|
|
14
|
+
startSequenceNumber: first.sequenceNumber,
|
|
15
|
+
endSequenceNumber: last.sequenceNumber,
|
|
16
|
+
approximateArrivalOfFirstRecord: first.at.toISOString(),
|
|
17
|
+
approximateArrivalOfLastRecord: last.at.toISOString(),
|
|
18
|
+
batchSize: records.length,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Identify the discarded records by shard and sequence-number bounds. */
|
|
22
|
+
export function streamFailureBatchInfo(arn, info) {
|
|
23
|
+
if (arn.startsWith("arn:aws:dynamodb:"))
|
|
24
|
+
return { DDBStreamBatchInfo: info };
|
|
25
|
+
return { KinesisBatchInfo: info };
|
|
26
|
+
}
|
|
@@ -14,6 +14,7 @@ import type { SimLambdaStreamRecordTime } from "./sim-lambda-stream-record-times
|
|
|
14
14
|
* to and the instants its records are aged from.
|
|
15
15
|
*/
|
|
16
16
|
export declare class SimLambdaStreamBatchOutcome {
|
|
17
|
+
readonly functionError: boolean;
|
|
17
18
|
readonly isHandled: boolean;
|
|
18
19
|
/**
|
|
19
20
|
* The records the batch carried, in stream order.
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* to and the instants its records are aged from.
|
|
13
13
|
*/
|
|
14
14
|
export class SimLambdaStreamBatchOutcome {
|
|
15
|
+
functionError;
|
|
15
16
|
isHandled;
|
|
16
17
|
/**
|
|
17
18
|
* The records the batch carried, in stream order.
|
|
@@ -19,6 +20,7 @@ export class SimLambdaStreamBatchOutcome {
|
|
|
19
20
|
records;
|
|
20
21
|
rewindTo;
|
|
21
22
|
constructor(properties) {
|
|
23
|
+
this.functionError = properties.functionError ?? false;
|
|
22
24
|
this.isHandled = properties.isHandled;
|
|
23
25
|
this.records = properties.records;
|
|
24
26
|
this.rewindTo = properties.rewindTo;
|
|
@@ -33,7 +35,11 @@ export class SimLambdaStreamBatchOutcome {
|
|
|
33
35
|
* A batch the function did not take, which is read again from where it was.
|
|
34
36
|
*/
|
|
35
37
|
static failed(records) {
|
|
36
|
-
return new SimLambdaStreamBatchOutcome({
|
|
38
|
+
return new SimLambdaStreamBatchOutcome({
|
|
39
|
+
isHandled: false,
|
|
40
|
+
records,
|
|
41
|
+
functionError: true,
|
|
42
|
+
});
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
39
45
|
* A batch the function reported failing partway through, which is read again
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SimLambdaFunction } from "../../function/sim-lambda-function.js";
|
|
2
|
+
import type { SimLambdaEventSourceStreamProgressBatch } from "../stream/sim-lambda-event-source-streams.js";
|
|
3
|
+
import type { SimLambdaStreamBatchOutcome } from "./sim-lambda-stream-batch-outcome.js";
|
|
4
|
+
import type { SimLambdaStreamProgress } from "./sim-lambda-stream-progress.js";
|
|
5
|
+
import type { SimLambdaStreamRecordTime } from "./sim-lambda-stream-record-times.js";
|
|
6
|
+
interface StreamBatchProcessing<RecordType> {
|
|
7
|
+
readonly batch: SimLambdaEventSourceStreamProgressBatch & {
|
|
8
|
+
readonly records: readonly RecordType[];
|
|
9
|
+
};
|
|
10
|
+
readonly simFunction: SimLambdaFunction;
|
|
11
|
+
readonly progress: SimLambdaStreamProgress;
|
|
12
|
+
readonly times: (records: readonly RecordType[]) => readonly SimLambdaStreamRecordTime[];
|
|
13
|
+
readonly deliver: (records: readonly RecordType[]) => Promise<SimLambdaStreamBatchOutcome>;
|
|
14
|
+
}
|
|
15
|
+
/** Check record age, invoke live records, and apply the batch outcome. */
|
|
16
|
+
export declare function processSimLambdaStreamBatch<RecordType>(properties: StreamBatchProcessing<RecordType>): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Check record age, invoke live records, and apply the batch outcome. */
|
|
2
|
+
export async function processSimLambdaStreamBatch(properties) {
|
|
3
|
+
const { batch, progress, simFunction } = properties;
|
|
4
|
+
if (batch.records.length === 0) {
|
|
5
|
+
progress.caughtUp(batch);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const firstLive = await progress.before(properties.times(batch.records), batch, simFunction);
|
|
9
|
+
if (firstLive === batch.records.length)
|
|
10
|
+
return;
|
|
11
|
+
await progress.after(await properties.deliver(batch.records.slice(firstLive)), batch, simFunction);
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PollSchedule } from "../../../../util/background/poll-schedule.js";
|
|
2
|
+
import type { SimLambdaEventSourceStart } from "../sim-lambda-event-source-starting-position.js";
|
|
3
|
+
import type { SimLambdaEventSourceStreamPosition, SimLambdaEventSourceStreamProgressBatch } from "../stream/sim-lambda-event-source-streams.js";
|
|
4
|
+
import type { SimLambdaStreamRetryAttempt } from "./sim-lambda-stream-retry.js";
|
|
5
|
+
/** Keep the next read position and schedule consistent when a batch finishes or retries. */
|
|
6
|
+
export declare class SimLambdaStreamCursor {
|
|
7
|
+
private readonly schedule;
|
|
8
|
+
private readonly checkpoint;
|
|
9
|
+
constructor(start: SimLambdaEventSourceStart, schedule: PollSchedule);
|
|
10
|
+
get position(): SimLambdaEventSourceStreamPosition;
|
|
11
|
+
advanceTo(position: SimLambdaEventSourceStreamPosition): void;
|
|
12
|
+
pollNow(): void;
|
|
13
|
+
handled(batch: SimLambdaEventSourceStreamProgressBatch): void;
|
|
14
|
+
resume(attempt: SimLambdaStreamRetryAttempt): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SimLambdaStreamCheckpoint } from "./sim-lambda-stream-checkpoint.js";
|
|
2
|
+
/** Keep the next read position and schedule consistent when a batch finishes or retries. */
|
|
3
|
+
export class SimLambdaStreamCursor {
|
|
4
|
+
schedule;
|
|
5
|
+
checkpoint;
|
|
6
|
+
constructor(start, schedule) {
|
|
7
|
+
this.schedule = schedule;
|
|
8
|
+
this.checkpoint = new SimLambdaStreamCheckpoint(start);
|
|
9
|
+
}
|
|
10
|
+
get position() {
|
|
11
|
+
return this.checkpoint.position;
|
|
12
|
+
}
|
|
13
|
+
advanceTo(position) {
|
|
14
|
+
this.checkpoint.advanceTo(position);
|
|
15
|
+
}
|
|
16
|
+
pollNow() {
|
|
17
|
+
this.schedule.now();
|
|
18
|
+
}
|
|
19
|
+
handled(batch) {
|
|
20
|
+
this.advanceTo(batch.next);
|
|
21
|
+
if (!batch.drained)
|
|
22
|
+
this.pollNow();
|
|
23
|
+
}
|
|
24
|
+
resume(attempt) {
|
|
25
|
+
this.advanceTo(attempt.position);
|
|
26
|
+
this.schedule.afterSeconds(attempt.afterSeconds);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SimLambdaStreamBatchAge } from "./sim-lambda-stream-batch-age.js";
|
|
2
|
+
import type { SimLambdaStreamRecordTime } from "./sim-lambda-stream-record-times.js";
|
|
3
|
+
import type { SimLambdaFunction } from "../../function/sim-lambda-function.js";
|
|
4
|
+
import type { SimLambdaStreamFailureDestination } from "./sim-lambda-stream-failure-destination.js";
|
|
5
|
+
import type { SimLambdaEventSourceStreamProgressBatch } from "../stream/sim-lambda-event-source-streams.js";
|
|
6
|
+
import type { SimLambdaStreamCursor } from "./sim-lambda-stream-cursor.js";
|
|
7
|
+
interface StreamExpiryProperties {
|
|
8
|
+
readonly age: SimLambdaStreamBatchAge;
|
|
9
|
+
readonly cursor: SimLambdaStreamCursor;
|
|
10
|
+
readonly failures: SimLambdaStreamFailureDestination;
|
|
11
|
+
readonly handled: (batch: SimLambdaEventSourceStreamProgressBatch) => void;
|
|
12
|
+
}
|
|
13
|
+
/** Advance past expired records and notify their destination before processing live records. */
|
|
14
|
+
export declare class SimLambdaStreamExpiry {
|
|
15
|
+
private readonly properties;
|
|
16
|
+
constructor(properties: StreamExpiryProperties);
|
|
17
|
+
before(records: readonly SimLambdaStreamRecordTime[], batch: SimLambdaEventSourceStreamProgressBatch, simFunction: SimLambdaFunction): Promise<number>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Advance past expired records and notify their destination before processing live records. */
|
|
2
|
+
export class SimLambdaStreamExpiry {
|
|
3
|
+
properties;
|
|
4
|
+
constructor(properties) {
|
|
5
|
+
this.properties = properties;
|
|
6
|
+
}
|
|
7
|
+
async before(records, batch, simFunction) {
|
|
8
|
+
const { age, cursor, failures, handled } = this.properties;
|
|
9
|
+
const discard = age.discarded(records);
|
|
10
|
+
if (discard === undefined)
|
|
11
|
+
return 0;
|
|
12
|
+
const discardedCount = discard.records.length;
|
|
13
|
+
const notification = failures.deliver(discard, batch, simFunction);
|
|
14
|
+
if (discardedCount === records.length) {
|
|
15
|
+
handled(batch);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
cursor.advanceTo(age.firstLivePosition(records, discardedCount));
|
|
19
|
+
}
|
|
20
|
+
await notification;
|
|
21
|
+
return discardedCount;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SimLambdaStreamFailureRecord, StreamFailureRecordProperties } from "./sim-lambda-stream-failure-record.js";
|
|
2
|
+
/** Build invocation metadata for a stream failure notification. */
|
|
3
|
+
export declare function streamFailureContext(properties: StreamFailureRecordProperties): Pick<SimLambdaStreamFailureRecord, "requestContext" | "responseContext">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
/** Build invocation metadata for a stream failure notification. */
|
|
3
|
+
export function streamFailureContext(properties) {
|
|
4
|
+
return {
|
|
5
|
+
requestContext: {
|
|
6
|
+
requestId: randomUUID(),
|
|
7
|
+
functionArn: properties.mapping.functionArn,
|
|
8
|
+
condition: properties.discard.condition,
|
|
9
|
+
approximateInvokeCount: properties.invokeCount,
|
|
10
|
+
},
|
|
11
|
+
...(properties.invokeCount > 0 && {
|
|
12
|
+
responseContext: {
|
|
13
|
+
statusCode: 200,
|
|
14
|
+
executedVersion: properties.simFunction.version,
|
|
15
|
+
...(properties.functionError && { functionError: "Unhandled" }),
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SimLambdaStreamBatchOutcome } from "./sim-lambda-stream-batch-outcome.js";
|
|
2
|
+
import type { SimLambdaFunction } from "../../function/sim-lambda-function.js";
|
|
3
|
+
import type { SimLambdaEventSourceMapping } from "../sim-lambda-event-source-mapping.js";
|
|
4
|
+
import type { SimLambdaEventSourceStreamProgressBatch } from "../stream/sim-lambda-event-source-streams.js";
|
|
5
|
+
import { type SimLambdaStreamDiscard } from "./sim-lambda-stream-failure-record.js";
|
|
6
|
+
/** Count invocations and send discarded batch metadata through the destination service. */
|
|
7
|
+
export declare class SimLambdaStreamFailureDestination {
|
|
8
|
+
private readonly mapping;
|
|
9
|
+
private invokeCount;
|
|
10
|
+
private functionError;
|
|
11
|
+
constructor(mapping: SimLambdaEventSourceMapping);
|
|
12
|
+
invoked(outcome: SimLambdaStreamBatchOutcome): void;
|
|
13
|
+
reset(): void;
|
|
14
|
+
deliver(discard: SimLambdaStreamDiscard | undefined, batch: SimLambdaEventSourceStreamProgressBatch, simFunction: SimLambdaFunction): Promise<void>;
|
|
15
|
+
}
|