本文整理汇总了Golang中github.com/sendgridlabs/go-kinesis.Kinesis类的典型用法代码示例。如果您正苦于以下问题:Golang Kinesis类的具体用法?Golang Kinesis怎么用?Golang Kinesis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kinesis类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CreateStream
// CreateStream creates a new stream
func CreateStream(k *kinesis.Kinesis, tempStreamName string, shards int) bool {
if err := k.CreateStream(tempStreamName, shards); err != nil {
return false
}
// wait for Stream ready state
timeout := make(chan bool, 30)
resp := &kinesis.DescribeStreamResp{}
log.Printf("Waiting for stream to be created")
for {
args := kinesis.NewArgs()
args.Add("StreamName", tempStreamName)
resp, _ = k.DescribeStream(args)
log.Printf(".")
if resp.StreamDescription.StreamStatus != "ACTIVE" {
time.Sleep(4 * time.Second)
timeout <- true
} else {
break
}
}
return true
}
开发者ID:vly,项目名称:haystack,代码行数:26,代码来源:producer_api.go
示例2: getRecords
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
}
}
开发者ID:bohford,项目名称:go-kinesis,代码行数:29,代码来源:example.go
示例3: GetMessages
func GetMessages(k *kinesis.Kinesis, streamName string, shardID string) (out [][]byte, ok bool) {
shardIterator := GetShardIterator(k, streamName, shardID)
for {
args := kinesis.NewArgs()
args.Add("ShardIterator", shardIterator)
recordResp, err := k.GetRecords(args)
if err == nil {
if len(recordResp.Records) > 0 {
for _, d := range recordResp.Records {
res, err := d.GetData()
if err != nil {
LogFile(err.Error())
}
//fmt.Printf("GetRecords Data: %v, err: %v\n", string(res), err)
out = append(out, res)
}
} else {
break
}
}
shardIterator = recordResp.NextShardIterator
}
return out, true
}
开发者ID:vly,项目名称:haystack,代码行数:29,代码来源:consumer.go
示例4: GetShardIterator
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
}
开发者ID:vly,项目名称:haystack,代码行数:8,代码来源:consumer.go
示例5: SendMessage
// SendMessage generates a new JSON blob and sends to a stream
func SendMessage(k *kinesis.Kinesis, streamName string, msg *Message, comms chan bool) {
args := kinesis.NewArgs()
args.Add("StreamName", streamName)
args.Add("PartitionKey", fmt.Sprintf("partitionKey-%d", 1))
if data, ok := msg.ToJSON(); ok {
args.AddData(data)
if _, err := k.PutRecord(args); err == nil {
comms <- true
return
}
}
log.Println("Failed to send message")
comms <- false
return
}
开发者ID:vly,项目名称:haystack,代码行数:16,代码来源:producer_api.go
示例6: CheckStream
// CheckStream verifies whether a stream already exists
func CheckStream(k *kinesis.Kinesis, streamname string) bool {
args := kinesis.NewArgs()
args.Add("StreamName", streamname)
temp, err := k.ListStreams(args)
if err != nil {
log.Println("Could not obtain list of streams.")
} else {
for _, b := range temp.StreamNames {
if b == streamname {
return true
}
}
}
return false
}
开发者ID:vly,项目名称:haystack,代码行数:17,代码来源:producer_api.go
示例7: DeleteStream
// DeleteStream deletes an existing stream
func DeleteStream(k *kinesis.Kinesis, streamName string) bool {
if err := k.DeleteStream(streamName); err == nil {
return true
}
return false
}
开发者ID:vly,项目名称:haystack,代码行数:7,代码来源:producer_api.go
注:本文中的github.com/sendgridlabs/go-kinesis.Kinesis类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论