Skip to content

Commit

Permalink
Add shard iterator type flag to kinesis command
Browse files Browse the repository at this point in the history
  • Loading branch information
sam701 committed Aug 25, 2016
1 parent e448561 commit 93c71a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

## Install

[We provide binaries for all releases through GitHub](https://github.com/sam701/awstools/releases). The latest release is [0.9.2](https://github.com/sam701/awstools/releases/latest).
[We provide binaries for all releases through GitHub](https://github.com/sam701/awstools/releases). The latest release is [0.9.3](https://github.com/sam701/awstools/releases/latest).

To install `awstools` choose the binary for your architecture (either OSX or Linux), run a download and use `chmod` to make it executable.

### OSX

```sh
$ curl -o awstools -SsL https://github.com/sam701/awstools/releases/download/0.9.2/awstools_darwin_amd64
$ curl -o awstools -SsL https://github.com/sam701/awstools/releases/download/0.9.3/awstools_darwin_amd64
$ chmod +x awstools
```

### Linux

```sh
$ curl -o awstools -SsL https://github.com/sam701/awstools/releases/download/0.9.2/awstools_linux_amd64
$ curl -o awstools -SsL https://github.com/sam701/awstools/releases/download/0.9.3/awstools_linux_amd64
$ chmod +x awstools
```

Expand Down
10 changes: 7 additions & 3 deletions kinesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func kinesisPrintRecords(c *cli.Context) error {
}

for _, shard := range dsr.StreamDescription.Shards {
go searchInShard(client, streamName, shard.ShardId, c.StringSlice("pattern"))
go searchInShard(client, streamName, shard.ShardId, c.StringSlice("pattern"), c.Bool("trim-horizon"))
}

ch := make(chan bool)
Expand All @@ -50,11 +50,15 @@ func kinesisPrintRecords(c *cli.Context) error {
return nil
}

func searchInShard(client *kinesis.Kinesis, streamName string, shardId *string, patterns []string) {
func searchInShard(client *kinesis.Kinesis, streamName string, shardId *string, patterns []string, trimHorizon bool) {
shardIteratorType := "LATEST"
if trimHorizon {
shardIteratorType = "TRIM_HORIZON"
}
itOut, err := client.GetShardIterator(&kinesis.GetShardIteratorInput{
StreamName: aws.String(streamName),
ShardId: shardId,
ShardIteratorType: aws.String("LATEST"),
ShardIteratorType: aws.String(shardIteratorType),
})
if err != nil {
log.Fatalln("ERROR", err)
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func main() {
app := cli.NewApp()
app.Name = "awstools"
app.Version = "0.9.2"
app.Version = "0.9.3"
app.Usage = "AWS tools"
app.Flags = []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -111,6 +111,10 @@ func main() {
Name: "search-stream, s",
Usage: "search `STREAM`",
},
cli.BoolFlag{
Name: "trim-horizon",
Usage: "Search from the last untrimmed record in the shards",
},
cli.StringSliceFlag{
Name: "pattern, p",
Usage: "search for (case sensitive) `PATTERN`",
Expand Down

0 comments on commit 93c71a3

Please sign in to comment.