forked from harlow/kinesis-consumer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
92 lines (77 loc) · 2.13 KB
/
options.go
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
package consumer
import (
"time"
"github.com/aws/aws-sdk-go-v2/service/kinesis/types"
)
// Option is used to override defaults when creating a new Consumer
type Option func(*Consumer)
// WithGroup overrides the default storage
func WithGroup(group Group) Option {
return func(c *Consumer) {
c.group = group
}
}
// WithStore overrides the default storage
func WithStore(store Store) Option {
return func(c *Consumer) {
c.store = store
}
}
// 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 kinesisClient) Option {
return func(c *Consumer) {
c.client = client
}
}
// WithShardIteratorType overrides the starting point for the consumer
func WithShardIteratorType(t string) Option {
return func(c *Consumer) {
c.initialShardIteratorType = types.ShardIteratorType(t)
}
}
// WithTimestamp overrides the starting point for the consumer
func WithTimestamp(t time.Time) Option {
return func(c *Consumer) {
c.initialTimestamp = &t
}
}
// WithScanInterval overrides the scan interval for the consumer
func WithScanInterval(d time.Duration) Option {
return func(c *Consumer) {
c.scanInterval = d
}
}
// WithMaxRecords overrides the maximum number of records to be
// returned in a single GetRecords call for the consumer (specify a
// value of up to 10,000)
func WithMaxRecords(n int64) Option {
return func(c *Consumer) {
c.maxRecords = n
}
}
func WithAggregation(a bool) Option {
return func(c *Consumer) {
c.isAggregated = a
}
}
// ShardClosedHandler is a handler that will be called when the consumer has reached the end of a closed shard.
// No more records for that shard will be provided by the consumer.
// An error can be returned to stop the consumer.
type ShardClosedHandler = func(streamName, shardID string) error
func WithShardClosedHandler(h ShardClosedHandler) Option {
return func(c *Consumer) {
c.shardClosedHandler = h
}
}