Add logs for start scan and checkpoints

This commit is contained in:
Harlow Ward 2017-11-22 17:52:41 -08:00
parent 3770136f64
commit 4ffe3ec55a
3 changed files with 8 additions and 10 deletions

View file

@ -3,8 +3,8 @@ package consumer
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"sync"
"github.com/aws/aws-sdk-go/aws"
@ -77,6 +77,7 @@ func New(app, stream string, opts ...Option) (*Consumer, error) {
streamName: stream,
checkpoint: &noopCheckpoint{},
counter: &noopCounter{},
logger: log.New(os.Stderr, "kinesis-consumer: ", log.LstdFlags),
}
// set options
@ -86,11 +87,6 @@ func New(app, stream string, opts ...Option) (*Consumer, error) {
}
}
// provide default logger
if c.logger == nil {
c.logger = log.New(ioutil.Discard, "", log.LstdFlags)
}
// provide a default kinesis client
if c.client == nil {
c.client = kinesis.New(session.New(aws.NewConfig()))
@ -197,6 +193,8 @@ loop:
if err := c.checkpoint.Set(shardID, lastSeqNum); err != nil {
c.logger.Printf("set checkpoint error: %v", err)
}
c.logger.Println("checkpoint", shardID, len(resp.Records))
c.counter.Add("checkpoints", 1)
}

View file

@ -14,4 +14,4 @@ export AWS_SECRET_KEY=
### Run the consumer
$ go run main.go -a appName -s streamName
$ go run main.go --app appName --stream streamName

View file

@ -17,4 +17,4 @@ export AWS_SECRET_KEY=
### Running the code
$ curl https://s3.amazonaws.com/kinesis.test/users.txt > /tmp/users.txt
$ go run main.go -s streamName
$ go run main.go --stream streamName