Add logs for start scan and checkpoints
This commit is contained in:
parent
3770136f64
commit
4ffe3ec55a
3 changed files with 8 additions and 10 deletions
10
consumer.go
10
consumer.go
|
|
@ -3,8 +3,8 @@ package consumer
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
|
@ -77,6 +77,7 @@ func New(app, stream string, opts ...Option) (*Consumer, error) {
|
||||||
streamName: stream,
|
streamName: stream,
|
||||||
checkpoint: &noopCheckpoint{},
|
checkpoint: &noopCheckpoint{},
|
||||||
counter: &noopCounter{},
|
counter: &noopCounter{},
|
||||||
|
logger: log.New(os.Stderr, "kinesis-consumer: ", log.LstdFlags),
|
||||||
}
|
}
|
||||||
|
|
||||||
// set options
|
// 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
|
// provide a default kinesis client
|
||||||
if c.client == nil {
|
if c.client == nil {
|
||||||
c.client = kinesis.New(session.New(aws.NewConfig()))
|
c.client = kinesis.New(session.New(aws.NewConfig()))
|
||||||
|
|
@ -197,6 +193,8 @@ loop:
|
||||||
if err := c.checkpoint.Set(shardID, lastSeqNum); err != nil {
|
if err := c.checkpoint.Set(shardID, lastSeqNum); err != nil {
|
||||||
c.logger.Printf("set checkpoint error: %v", err)
|
c.logger.Printf("set checkpoint error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.logger.Println("checkpoint", shardID, len(resp.Records))
|
||||||
c.counter.Add("checkpoints", 1)
|
c.counter.Add("checkpoints", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,4 @@ export AWS_SECRET_KEY=
|
||||||
|
|
||||||
### Run the consumer
|
### Run the consumer
|
||||||
|
|
||||||
$ go run main.go -a appName -s streamName
|
$ go run main.go --app appName --stream streamName
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,4 @@ export AWS_SECRET_KEY=
|
||||||
### Running the code
|
### Running the code
|
||||||
|
|
||||||
$ curl https://s3.amazonaws.com/kinesis.test/users.txt > /tmp/users.txt
|
$ curl https://s3.amazonaws.com/kinesis.test/users.txt > /tmp/users.txt
|
||||||
$ go run main.go -s streamName
|
$ go run main.go --stream streamName
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue