forked from celestiaorg/celestia-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams.go
41 lines (34 loc) · 894 Bytes
/
params.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
package pruner
import (
"fmt"
"time"
)
type Option func(*Params)
type Params struct {
// pruneCycle is the frequency at which the pruning Service
// runs the ticker. If set to 0, the Service will not run.
pruneCycle time.Duration
}
func (p *Params) Validate() error {
if p.pruneCycle == time.Duration(0) {
return fmt.Errorf("invalid GC cycle given, value should be positive and non-zero")
}
return nil
}
func DefaultParams() Params {
return Params{
pruneCycle: time.Minute * 5,
}
}
// WithPruneCycle configures how often the pruning Service
// triggers a pruning cycle.
func WithPruneCycle(cycle time.Duration) Option {
return func(p *Params) {
p.pruneCycle = cycle
}
}
// WithPrunerMetrics is a utility function to turn on pruner metrics and that is
// expected to be "invoked" by the fx lifecycle.
func WithPrunerMetrics(s *Service) error {
return s.WithMetrics()
}