-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
50 lines (42 loc) · 1.02 KB
/
options.go
File metadata and controls
50 lines (42 loc) · 1.02 KB
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 chronicle
import (
"time"
log "github.com/xraph/go-utils/log"
)
// Option configures a Chronicle instance.
type Option func(*Chronicle) error
// WithStore sets the backing store for Chronicle.
func WithStore(s Storer) Option {
return func(c *Chronicle) error {
c.store = s
return nil
}
}
// WithLogger sets the logger for Chronicle.
func WithLogger(l log.Logger) Option {
return func(c *Chronicle) error {
c.logger = l
return nil
}
}
// WithBatchSize sets the maximum batch size before flushing.
func WithBatchSize(n int) Option {
return func(c *Chronicle) error {
c.config.BatchSize = n
return nil
}
}
// WithFlushInterval sets the maximum time between flushes.
func WithFlushInterval(d time.Duration) Option {
return func(c *Chronicle) error {
c.config.FlushInterval = d
return nil
}
}
// WithCryptoErasure enables or disables per-subject encryption for GDPR.
func WithCryptoErasure(enabled bool) Option {
return func(c *Chronicle) error {
c.config.EnableCryptoErasure = enabled
return nil
}
}