Skip to content

Commit

Permalink
Add DB.InitialMonitorDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Aug 19, 2024
1 parent d949e7e commit c4adec6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ type DB struct {
// Frequency at which to perform db sync.
MonitorInterval time.Duration

// Initial delay before monitoring loop starts
InitialMonitorDelay time.Duration

// List of replicas for the database.
// Must be set before calling Open().
Replicas []*Replica
Expand Down Expand Up @@ -1439,6 +1442,12 @@ func (db *DB) execCheckpoint(mode string) (err error) {

// monitor runs in a separate goroutine and monitors the database & WAL.
func (db *DB) monitor() {
select {
case <-db.ctx.Done():
return
case <-time.After(db.InitialMonitorDelay):
}

ticker := time.NewTicker(db.MonitorInterval)
defer ticker.Stop()

Expand Down

0 comments on commit c4adec6

Please sign in to comment.