@@ -29,21 +29,21 @@ import (
2929
3030// WALConfig is config for the Write Ahead Log.
3131type 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:"-"`
3838}
3939
4040// RegisterFlags adds the flags required to config this to the given FlagSet
4141func (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." )
4747}
4848
4949// WAL interface allows us to have a no-op WAL when the WAL is disabled.
@@ -77,15 +77,15 @@ type walWrapper struct {
7777
7878// newWAL creates a WAL object. If the WAL is disabled, then the returned WAL is a no-op WAL.
7979func newWAL (cfg WALConfig , userStatesFunc func () map [string ]* userState ) (WAL , error ) {
80- if ! cfg .walEnabled {
80+ if ! cfg .WALEnabled {
8181 return & noopWAL {}, nil
8282 }
8383
8484 var walRegistry prometheus.Registerer
8585 if cfg .metricsRegisterer != nil {
8686 walRegistry = prometheus .WrapRegistererWith (prometheus.Labels {"kind" : "wal" }, cfg .metricsRegisterer )
8787 }
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 )
8989 if err != nil {
9090 return nil , err
9191 }
@@ -158,11 +158,11 @@ func (w *walWrapper) Log(record *Record) error {
158158func (w * walWrapper ) run () {
159159 defer w .wait .Done ()
160160
161- if ! w .cfg .checkpointEnabled {
161+ if ! w .cfg .CheckpointEnabled {
162162 return
163163 }
164164
165- ticker := time .NewTicker (w .cfg .checkpointDuration )
165+ ticker := time .NewTicker (w .cfg .CheckpointDuration )
166166 defer ticker .Stop ()
167167
168168 for {
@@ -190,7 +190,7 @@ func (w *walWrapper) run() {
190190const checkpointPrefix = "checkpoint."
191191
192192func (w * walWrapper ) performCheckpoint () (err error ) {
193- if ! w .cfg .checkpointEnabled {
193+ if ! w .cfg .CheckpointEnabled {
194194 return nil
195195 }
196196
@@ -359,7 +359,7 @@ func (w *walWrapper) checkpointSeries(cp *wal.WAL, userID string, fp model.Finge
359359}
360360
361361func recoverFromWAL (ingester * Ingester ) (err error ) {
362- walDir := ingester .cfg .WALConfig .dir
362+ walDir := ingester .cfg .WALConfig .Dir
363363 // Use a local userStates, so we don't need to worry about locking.
364364 userStates := newUserStates (ingester .limiter , ingester .cfg , ingester .metrics )
365365
0 commit comments