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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
package kinesis
import (
"encoding/json"
)
type msi map[string]interface{}
type Query struct {
buffer msi
}
func NewEmptyQuery() *Query {
return &Query{msi{}}
}
func NewQueryWithStream(streamName string) *Query {
q := &Query{msi{}}
q.AddStreamName(streamName)
return q
}
func (q *Query) AddExclusiveStartShardId(shardId string) {
q.buffer["ExclusiveStartShardId"] = shardId
}
func (q *Query) AddLimit(limit int) {
q.buffer["Limit"] = limit
}
func (q *Query) AddStreamName(name string) {
q.buffer["StreamName"] = name
}
func (q *Query) AddShardCount(count int) {
q.buffer["ShardCount"] = count
}
func (q *Query) AddShardIterator(iterator string) {
q.buffer["ShardIterator"] = iterator
}
func (q *Query) AddShardId(id string) {
q.buffer["ShardId"] = id
}
func (q *Query) AddShardIteratorType(t ShardIteratorType) {
q.buffer["ShardIteratorType"] = t
}
func (q *Query) AddStartingSequenceNumber(sequenceNumber string) {
q.buffer["StartingSequenceNumber"] = sequenceNumber
}
func (q *Query) AddData(data []byte) {
q.buffer["Data"] = data
}
func (q *Query) AddExplicitHashKey(hashKey string) {
q.buffer["ExplicitHashKey"] = hashKey
}
func (q *Query) AddPartitionKey(partitionKey string) {
q.buffer["PartitionKey"] = partitionKey
}
func (q *Query) AddSequenceNumberForOrdering(sequenceNumber string) {
q.buffer["SequenceNumberForOrdering"] = sequenceNumber
}
func (q *Query) AddRecords(records []PutRecordsRequestEntry) {
q.buffer["Records"] = records
}
func (q *Query) AddShardToMerge(shard string) {
q.buffer["ShardToMerge"] = shard
}
func (q *Query) AddAdjacentShardToMerge(shard string) {
q.buffer["AdjacentShardToMerge"] = shard
}
func (q *Query) AddShardToSplit(shard string) {
q.buffer["ShardToSplit"] = shard
}
func (q *Query) AddNewStartingHashKey(hashKey string) {
q.buffer["NewStartingHashKey"] = hashKey
}
func (q *Query) String() string {
bytes, err := json.Marshal(q.buffer)
if err != nil {
panic(err)
}
return string(bytes)
}
|