-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
41 lines (32 loc) · 690 Bytes
/
config.go
File metadata and controls
41 lines (32 loc) · 690 Bytes
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
package loader
import (
"context"
"time"
)
// ContextFactory creates context to be used by LoadFunc
type ContextFactory func() context.Context
var defaultContextFactory ContextFactory = func() context.Context {
return context.Background()
}
type config struct {
cf ContextFactory
driver CacheDriver
ttl time.Duration
errTtl time.Duration
}
type Option func(cfg *config)
func WithDriver(driver CacheDriver) Option {
return func(cfg *config) {
cfg.driver = driver
}
}
func WithErrorTTL(ttl time.Duration) Option {
return func(cfg *config) {
cfg.errTtl = ttl
}
}
func WithContextFactory(cf ContextFactory) Option {
return func(cfg *config) {
cfg.cf = cf
}
}