@@ -29,21 +29,21 @@ import (
29
29
30
30
// WALConfig is config for the Write Ahead Log.
31
31
type WALConfig struct {
32
- walEnabled bool `yaml:"wal_enabled,omitempty"`
33
- checkpointEnabled bool `yaml:"checkpoint_enabled,omitempty"`
34
- recover bool `yaml:"recover_from_wal,omitempty"`
35
- dir string `yaml:"wal_dir,omitempty"`
36
- checkpointDuration time.Duration `yaml:"checkpoint_duration,omitempty"`
37
- metricsRegisterer prometheus.Registerer
32
+ WALEnabled bool `yaml:"wal_enabled,omitempty"`
33
+ CheckpointEnabled bool `yaml:"checkpoint_enabled,omitempty"`
34
+ Recover bool `yaml:"recover_from_wal,omitempty"`
35
+ Dir string `yaml:"wal_dir,omitempty"`
36
+ CheckpointDuration time.Duration `yaml:"checkpoint_duration,omitempty"`
37
+ metricsRegisterer prometheus.Registerer `yaml:"-"`
38
38
}
39
39
40
40
// RegisterFlags adds the flags required to config this to the given FlagSet
41
41
func (cfg * WALConfig ) RegisterFlags (f * flag.FlagSet ) {
42
- f .StringVar (& cfg .dir , "ingester.wal-dir" , "wal" , "Directory to store the WAL and/or recover from WAL." )
43
- f .BoolVar (& cfg .recover , "ingester.recover-from-wal" , false , "Recover data from existing WAL irrespective of WAL enabled/disabled." )
44
- f .BoolVar (& cfg .walEnabled , "ingester.wal-enabled" , false , "Enable writing of ingested data into WAL." )
45
- f .BoolVar (& cfg .checkpointEnabled , "ingester.checkpoint-enabled" , false , "Enable checkpointing of in-memory chunks." )
46
- f .DurationVar (& cfg .checkpointDuration , "ingester.checkpoint-duration" , 30 * time .Minute , "Interval at which checkpoints should be created." )
42
+ f .StringVar (& cfg .Dir , "ingester.wal-dir" , "wal" , "Directory to store the WAL and/or recover from WAL." )
43
+ f .BoolVar (& cfg .Recover , "ingester.recover-from-wal" , false , "Recover data from existing WAL irrespective of WAL enabled/disabled." )
44
+ f .BoolVar (& cfg .WALEnabled , "ingester.wal-enabled" , false , "Enable writing of ingested data into WAL." )
45
+ f .BoolVar (& cfg .CheckpointEnabled , "ingester.checkpoint-enabled" , false , "Enable checkpointing of in-memory chunks." )
46
+ f .DurationVar (& cfg .CheckpointDuration , "ingester.checkpoint-duration" , 30 * time .Minute , "Interval at which checkpoints should be created." )
47
47
}
48
48
49
49
// WAL interface allows us to have a no-op WAL when the WAL is disabled.
@@ -77,15 +77,15 @@ type walWrapper struct {
77
77
78
78
// newWAL creates a WAL object. If the WAL is disabled, then the returned WAL is a no-op WAL.
79
79
func newWAL (cfg WALConfig , userStatesFunc func () map [string ]* userState ) (WAL , error ) {
80
- if ! cfg .walEnabled {
80
+ if ! cfg .WALEnabled {
81
81
return & noopWAL {}, nil
82
82
}
83
83
84
84
var walRegistry prometheus.Registerer
85
85
if cfg .metricsRegisterer != nil {
86
86
walRegistry = prometheus .WrapRegistererWith (prometheus.Labels {"kind" : "wal" }, cfg .metricsRegisterer )
87
87
}
88
- tsdbWAL , err := wal .NewSize (util .Logger , walRegistry , cfg .dir , wal .DefaultSegmentSize / 4 , true )
88
+ tsdbWAL , err := wal .NewSize (util .Logger , walRegistry , cfg .Dir , wal .DefaultSegmentSize / 4 , true )
89
89
if err != nil {
90
90
return nil , err
91
91
}
@@ -158,11 +158,11 @@ func (w *walWrapper) Log(record *Record) error {
158
158
func (w * walWrapper ) run () {
159
159
defer w .wait .Done ()
160
160
161
- if ! w .cfg .checkpointEnabled {
161
+ if ! w .cfg .CheckpointEnabled {
162
162
return
163
163
}
164
164
165
- ticker := time .NewTicker (w .cfg .checkpointDuration )
165
+ ticker := time .NewTicker (w .cfg .CheckpointDuration )
166
166
defer ticker .Stop ()
167
167
168
168
for {
@@ -190,7 +190,7 @@ func (w *walWrapper) run() {
190
190
const checkpointPrefix = "checkpoint."
191
191
192
192
func (w * walWrapper ) performCheckpoint () (err error ) {
193
- if ! w .cfg .checkpointEnabled {
193
+ if ! w .cfg .CheckpointEnabled {
194
194
return nil
195
195
}
196
196
@@ -359,7 +359,7 @@ func (w *walWrapper) checkpointSeries(cp *wal.WAL, userID string, fp model.Finge
359
359
}
360
360
361
361
func recoverFromWAL (ingester * Ingester ) (err error ) {
362
- walDir := ingester .cfg .WALConfig .dir
362
+ walDir := ingester .cfg .WALConfig .Dir
363
363
// Use a local userStates, so we don't need to worry about locking.
364
364
userStates := newUserStates (ingester .limiter , ingester .cfg , ingester .metrics )
365
365
0 commit comments