Skip to content

Commit 5d02e9e

Browse files
authored
Merge pull request #96 from awsryancwj/main
add go snippet for lambda-kinesis
2 parents d8ddf08 + 5a3c8d7 commit 5d02e9e

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

integration-kinesis-to-lambda/main.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/aws/aws-lambda-go/events"
8+
"github.com/aws/aws-lambda-go/lambda"
9+
)
10+
11+
func handler(ctx context.Context, kinesisEvent events.KinesisEvent) error {
12+
if len(kinesisEvent.Records) == 0 {
13+
log.Printf("empty Kinesis event received")
14+
return nil
15+
}
16+
17+
for _, record := range kinesisEvent.Records {
18+
log.Printf("processed Kinesis event with EventId: %v", record.EventID)
19+
recordDataBytes := record.Kinesis.Data
20+
recordDataText := string(recordDataBytes)
21+
log.Printf("record data: %v", recordDataText)
22+
// TODO: Do interesting work based on the new data
23+
}
24+
log.Printf("successfully processed %v records", len(kinesisEvent.Records))
25+
return nil
26+
}
27+
28+
func main() {
29+
lambda.Start(handler)
30+
}

integration-kinesis-to-lambda/snippet-data.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Using AWS Lambda with Amazon Kinesis without Batch Item Handling.",
44
"type": "Integration",
55
"services": ["lambda", "kinesis"],
6-
"languages": ["Node", "TypeScript", ".NET","Java"],
6+
"languages": ["Node", "TypeScript", ".NET", "Java"],
77
"tags": [],
88
"introBox": {
99
"headline": "How it works",
@@ -63,6 +63,17 @@
6363
"language": "java"
6464
}
6565
]
66+
},
67+
{
68+
"id": "Go",
69+
"title": "Usage Example with Go:",
70+
"description": "Consuming Kinesis event with Lambda using Go without batch item handling.",
71+
"snippets": [
72+
{
73+
"snippetPath": "main.go",
74+
"language": "go"
75+
}
76+
]
6677
}
6778
]
6879
}

0 commit comments

Comments
 (0)