-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoption.go
34 lines (28 loc) · 905 Bytes
/
option.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
package dataloader
type option[K any, V any, C comparable] func(*loader[K, V, C])
func WithBatch[K any, V any, C comparable](useBatch bool) option[K, V, C] {
return func(l *loader[K, V, C]) {
l.maxBatchSize = 1
}
}
func WithMaxBatchSize[K any, V any, C comparable](maxBatchSize int) option[K, V, C] {
return func(l *loader[K, V, C]) {
l.maxBatchSize = maxBatchSize
}
}
func WithBatchScheduleFn[K any, V any, C comparable](batchScheduleFn BatchScheduleFn) option[K, V, C] {
return func(l *loader[K, V, C]) {
l.batchScheduleFn = batchScheduleFn
}
}
func WithCacheKeyFn[K any, V any, C comparable](cacheKeyFn CacheKeyFn[K, C]) option[K, V, C] {
return func(l *loader[K, V, C]) {
l.cacheKeyFn = cacheKeyFn
}
}
func WithCacheMap[K any, V any, C comparable](cacheMap CacheMap[C, *Thunk[V]]) option[K, V, C] {
return func(l *loader[K, V, C]) {
<-l.cacheMap
l.cacheMap <- cacheMap
}
}