-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
stream.ts
54 lines (48 loc) · 1.47 KB
/
stream.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import lambda = require('@aws-cdk/aws-lambda');
import {Duration} from '@aws-cdk/core';
/**
* @internal
*/
export interface StreamEventSourceProps {
/**
* The largest number of records that AWS Lambda will retrieve from your event
* source at the time of invoking your function. Your function receives an
* event with all the retrieved records.
*
* Valid Range: Minimum value of 1. Maximum value of 10000.
*
* @default 100
*/
readonly batchSize?: number;
/**
* Where to begin consuming the stream.
*/
readonly startingPosition: lambda.StartingPosition;
/**
* The maximum amount of time to gather records before invoking the function.
* Maximum of Duration.minutes(5)
*
* @default Duration.seconds(0)
*/
readonly maxBatchingWindow?: Duration;
}
/**
* Use an stream as an event source for AWS Lambda.
*
* @internal
*/
export abstract class StreamEventSource implements lambda.IEventSource {
protected constructor(protected readonly props: StreamEventSourceProps) {
}
public bind(_target: lambda.IFunction): void {
throw new Error('Cannot bind StreamEventSource, use DynamoEventSource or KinesisEventSource');
}
protected enrichMappingOptions(options: lambda.EventSourceMappingOptions): lambda.EventSourceMappingOptions {
return {
...options,
batchSize: this.props.batchSize || 100,
startingPosition: this.props.startingPosition,
maxBatchingWindow: this.props.maxBatchingWindow,
};
}
}