-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.go
50 lines (38 loc) · 1012 Bytes
/
config.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
package subee
import (
"log"
"os"
"time"
)
const (
// DefaultChunkSize is the default maximum chunked message size per consuming.
DefaultChunkSize = 4
// DefaultFlushInterval is the default maximum flush interval to receive messages.
DefaultFlushInterval = 10 * time.Second
)
// Config represents the configuration for subee.
type Config struct {
ChunkSize int
AckImmediately bool
FlushInterval time.Duration
Logger Logger
StatsHandler StatsHandler
BatchConsumer BatchConsumer
BatchConsumerInterceptors []BatchConsumerInterceptor
Consumer Consumer
ConsumerInterceptors []ConsumerInterceptor
}
func (c *Config) apply(opts []Option) {
for _, f := range opts {
f(c)
}
}
// newDefaultConfig returns the *Config with default value set.
func newDefaultConfig() *Config {
return &Config{
ChunkSize: DefaultChunkSize,
FlushInterval: DefaultFlushInterval,
Logger: log.New(os.Stdout, "", log.LstdFlags),
StatsHandler: new(NopStatsHandler),
}
}