-
Notifications
You must be signed in to change notification settings - Fork 0
/
consumer.go
42 lines (32 loc) · 958 Bytes
/
consumer.go
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
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis"
)
func main() {
kc := kinesis.New(session.New(), &aws.Config{Region: aws.String("us-east-1")})
shard_itr_params := &kinesis.GetShardIteratorInput{
ShardId: aws.String("0"), // Required
ShardIteratorType: aws.String("TRIM_HORIZON"), // Required
StreamName: aws.String("zachstream"), // Required
}
shard_itr_raw, err := kc.GetShardIterator(shard_itr_params)
if err != nil {
fmt.Println(err.Error())
return
}
shard_itr := shard_itr_raw.ShardIterator
records_params := &kinesis.GetRecordsInput{
ShardIterator: shard_itr, // Required
}
records_raw, err := kc.GetRecords(records_params)
if err != nil {
fmt.Println(err.Error())
return
}
for i := 0; i < len(records_raw.Records); i += 1 {
fmt.Println(string(records_raw.Records[i].Data[:]))
}
}