-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DynamoDB and Kinesis Time Window events and response models (#441)
- Loading branch information
Showing
8 changed files
with
280 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{ | ||
"Records":[ | ||
{ | ||
"eventID":"1", | ||
"eventName":"INSERT", | ||
"eventVersion":"1.0", | ||
"eventSource":"aws:dynamodb", | ||
"awsRegion":"us-east-1", | ||
"dynamodb":{ | ||
"ApproximateCreationDateTime": 1480642020, | ||
"Keys":{ | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"NewImage":{ | ||
"Message":{ | ||
"S":"New item!" | ||
}, | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"SequenceNumber":"111", | ||
"SizeBytes":26, | ||
"StreamViewType":"NEW_AND_OLD_IMAGES" | ||
}, | ||
"eventSourceARN":"stream-ARN" | ||
}, | ||
{ | ||
"eventID":"2", | ||
"eventName":"MODIFY", | ||
"eventVersion":"1.0", | ||
"eventSource":"aws:dynamodb", | ||
"awsRegion":"us-east-1", | ||
"dynamodb":{ | ||
"ApproximateCreationDateTime": 1480642020, | ||
"Keys":{ | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"NewImage":{ | ||
"Message":{ | ||
"S":"This item has changed" | ||
}, | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"OldImage":{ | ||
"Message":{ | ||
"S":"New item!" | ||
}, | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"SequenceNumber":"222", | ||
"SizeBytes":59, | ||
"StreamViewType":"NEW_AND_OLD_IMAGES" | ||
}, | ||
"eventSourceARN":"stream-ARN" | ||
}, | ||
{ | ||
"eventID":"3", | ||
"eventName":"REMOVE", | ||
"eventVersion":"1.0", | ||
"eventSource":"aws:dynamodb", | ||
"awsRegion":"us-east-1", | ||
"dynamodb":{ | ||
"ApproximateCreationDateTime": 1480642020, | ||
"Keys":{ | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"OldImage":{ | ||
"Message":{ | ||
"S":"This item has changed" | ||
}, | ||
"Id":{ | ||
"N":"101" | ||
} | ||
}, | ||
"SequenceNumber":"333", | ||
"SizeBytes":38, | ||
"StreamViewType":"NEW_AND_OLD_IMAGES" | ||
}, | ||
"eventSourceARN":"stream-ARN" | ||
} | ||
], | ||
"window": { | ||
"start": "2020-07-30T17:00:00Z", | ||
"end": "2020-07-30T17:05:00Z" | ||
}, | ||
"state": { | ||
"1": "state1" | ||
}, | ||
"shardId": "shard123456789", | ||
"eventSourceARN": "stream-ARN", | ||
"isFinalInvokeForWindow": false, | ||
"isWindowTerminatedEarly": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
{ | ||
"Records": [ | ||
{ | ||
"kinesis": { | ||
"kinesisSchemaVersion": "1.0", | ||
"partitionKey": "1", | ||
"sequenceNumber": "49590338271490256608559692538361571095921575989136588898", | ||
"data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==", | ||
"approximateArrivalTimestamp": 1607497475.000 | ||
}, | ||
"eventSource": "aws:kinesis", | ||
"eventVersion": "1.0", | ||
"eventID": "shardId-000000000006:49590338271490256608559692538361571095921575989136588898", | ||
"eventName": "aws:kinesis:record", | ||
"invokeIdentityArn": "arn:aws:iam::123456789012:role/lambda-kinesis-role", | ||
"awsRegion": "us-east-1", | ||
"eventSourceARN": "arn:aws:kinesis:us-east-1:123456789012:stream/lambda-stream" | ||
} | ||
], | ||
"window": { | ||
"start": "2020-12-09T07:04:00Z", | ||
"end": "2020-12-09T07:06:00Z" | ||
}, | ||
"state": { | ||
"1": "state 1", | ||
"2": "state 2" | ||
}, | ||
"shardId": "shardId-000000000006", | ||
"eventSourceARN": "arn:aws:kinesis:us-east-1:123456789012:stream/lambda-stream", | ||
"isFinalInvokeForWindow": false, | ||
"isWindowTerminatedEarly": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package events | ||
|
||
// Window is the object that captures the time window for the records in the event when using the tumbling windows feature | ||
// Kinesis: https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-windows | ||
// DDB: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows | ||
type Window struct { | ||
Start RFC3339EpochTime `json:"start"` | ||
End RFC3339EpochTime `json:"end"` | ||
} | ||
|
||
// TimeWindowProperties is the object that captures properties that relate to the tumbling windows feature | ||
// Kinesis: https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-windows | ||
// DDB: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows | ||
type TimeWindowProperties struct { | ||
// Time window for the records in the event. | ||
Window Window `json:"window"` | ||
|
||
// State being built up to this invoke in the time window. | ||
State map[string]string `json:"state"` | ||
|
||
// Shard id of the records | ||
ShardID string `json:"shardId"` | ||
|
||
// The event source ARN of the service that generated the event (eg. DynamoDB or Kinesis) | ||
EventSourceARN string `json:"eventSourceARN"` | ||
|
||
// Set to true for the last invoke of the time window. | ||
// Subsequent invoke will start a new time window along with a fresh state. | ||
IsFinalInvokeForWindow bool `json:"isFinalInvokeForWindow"` | ||
|
||
// Set to true if window is terminated prematurely. | ||
// Subsequent invoke will continue the same window with a fresh state. | ||
IsWindowTerminatedEarly bool `json:"isWindowTerminatedEarly"` | ||
} | ||
|
||
// TimeWindowEventResponseProperties is the object that captures response properties that relate to the tumbling windows feature | ||
// Kinesis: https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-windows | ||
// DDB: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows | ||
type TimeWindowEventResponseProperties struct { | ||
// State being built up to this invoke in the time window. | ||
State map[string]string `json:"state"` | ||
} |