2019-04-07 23:29:12 +00:00
|
|
|
package consumer
|
|
|
|
|
|
2019-08-14 16:33:35 +00:00
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/service/kinesis/kinesisiface"
|
|
|
|
|
)
|
2019-04-07 23:29:12 +00:00
|
|
|
|
|
|
|
|
// Option is used to override defaults when creating a new Consumer
|
|
|
|
|
type Option func(*Consumer)
|
|
|
|
|
|
2019-07-29 04:34:54 +00:00
|
|
|
// WithGroup overrides the default storage
|
|
|
|
|
func WithGroup(group Group) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.group = group
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-29 04:33:19 +00:00
|
|
|
// WithStore overrides the default storage
|
|
|
|
|
func WithStore(store Store) Option {
|
2019-04-07 23:29:12 +00:00
|
|
|
return func(c *Consumer) {
|
2019-07-29 04:18:40 +00:00
|
|
|
c.store = store
|
2019-04-07 23:29:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithLogger overrides the default logger
|
|
|
|
|
func WithLogger(logger Logger) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.logger = logger
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithCounter overrides the default counter
|
|
|
|
|
func WithCounter(counter Counter) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.counter = counter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithClient overrides the default client
|
|
|
|
|
func WithClient(client kinesisiface.KinesisAPI) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.client = client
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 17:54:01 +00:00
|
|
|
// WithShardIteratorType overrides the starting point for the consumer
|
2019-04-07 23:29:12 +00:00
|
|
|
func WithShardIteratorType(t string) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.initialShardIteratorType = t
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-14 16:33:35 +00:00
|
|
|
|
2019-09-01 01:43:26 +00:00
|
|
|
// WithTimestamp overrides the starting point for the consumer
|
2019-08-14 16:33:35 +00:00
|
|
|
func WithTimestamp(t time.Time) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.initialTimestamp = &t
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-17 18:22:10 +00:00
|
|
|
|
|
|
|
|
// WithScanInterval overrides the scan interval for the consumer
|
|
|
|
|
func WithScanInterval(d time.Duration) Option {
|
|
|
|
|
return func(c *Consumer) {
|
|
|
|
|
c.scanInterval = d
|
|
|
|
|
}
|
|
|
|
|
}
|