示例#1
0
func getRecords(ksis *kinesis.Kinesis, streamName, ShardId string) {
	args := kinesis.NewArgs()
	args.Add("StreamName", streamName)
	args.Add("ShardId", ShardId)
	args.Add("ShardIteratorType", "TRIM_HORIZON")
	resp10, _ := ksis.GetShardIterator(args)

	shardIterator := resp10.ShardIterator

	for {
		args = kinesis.NewArgs()
		args.Add("ShardIterator", shardIterator)
		resp11, err := ksis.GetRecords(args)

		if len(resp11.Records) > 0 {
			fmt.Printf("GetRecords Data BEGIN\n")
			for _, d := range resp11.Records {
				res, err := d.GetData()
				fmt.Printf("GetRecords Data: %v, err: %v\n", string(res), err)
			}
			fmt.Printf("GetRecords Data END\n")
		} else if resp11.NextShardIterator == "" || shardIterator == resp11.NextShardIterator || err != nil {
			fmt.Printf("GetRecords ERROR: %v\n", err)
			break
		}

		shardIterator = resp11.NextShardIterator
	}
}
示例#2
0
文件: consumer.go 项目: vly/haystack
func GetShardIterator(k *kinesis.Kinesis, streamName string, shardId string) string {
	args := kinesis.NewArgs()
	args.Add("StreamName", streamName)
	args.Add("ShardId", shardId)
	args.Add("ShardIteratorType", "TRIM_HORIZON")
	a, _ := k.GetShardIterator(args)
	return a.ShardIterator
}