-
Notifications
You must be signed in to change notification settings - Fork 12
/
options.go
65 lines (54 loc) · 1.81 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
package storage
import (
"time"
"github.com/iotaledger/hive.go/db"
"github.com/iotaledger/hive.go/runtime/options"
"github.com/iotaledger/iota-core/pkg/storage/permanent"
"github.com/iotaledger/iota-core/pkg/storage/prunable"
iotago "github.com/iotaledger/iota.go/v4"
)
func WithDBEngine(optsDBEngine db.Engine) options.Option[Storage] {
return func(s *Storage) {
s.optsDBEngine = optsDBEngine
}
}
func WithAllowedDBEngines(optsAllowedDBEngines []db.Engine) options.Option[Storage] {
return func(s *Storage) {
s.optsAllowedDBEngines = optsAllowedDBEngines
}
}
func WithBucketManagerOptions(opts ...options.Option[prunable.BucketManager]) options.Option[Storage] {
return func(s *Storage) {
s.optsBucketManagerOptions = append(s.optsBucketManagerOptions, opts...)
}
}
func WithPruningDelay(optsPruningDelay iotago.EpochIndex) options.Option[Storage] {
return func(s *Storage) {
s.optsPruningDelay = optsPruningDelay
}
}
func WithPruningSizeEnable(pruningSizeEnabled bool) options.Option[Storage] {
return func(p *Storage) {
p.optPruningSizeEnabled = pruningSizeEnabled
}
}
func WithPruningSizeMaxTargetSizeBytes(pruningSizeTargetSizeBytes int64) options.Option[Storage] {
return func(p *Storage) {
p.optsPruningSizeMaxTargetSizeBytes = pruningSizeTargetSizeBytes
}
}
func WithPruningSizeReductionPercentage(pruningSizeReductionPercentage float64) options.Option[Storage] {
return func(p *Storage) {
p.optsPruningSizeReductionPercentage = pruningSizeReductionPercentage
}
}
func WithPruningSizeCooldownTime(cooldown time.Duration) options.Option[Storage] {
return func(p *Storage) {
p.optsPruningSizeCooldownTime = cooldown
}
}
func WithPermanentOptions(opts ...options.Option[permanent.Permanent]) options.Option[Storage] {
return func(s *Storage) {
s.optsPermanent = append(s.optsPermanent, opts...)
}
}