|
|
@ -325,6 +325,7 @@ type Manager struct { |
|
|
|
opts *ManagerOptions |
|
|
|
opts *ManagerOptions |
|
|
|
groups map[string]*Group |
|
|
|
groups map[string]*Group |
|
|
|
mtx sync.RWMutex |
|
|
|
mtx sync.RWMutex |
|
|
|
|
|
|
|
block chan struct{} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ManagerOptions bundles options for the Manager.
|
|
|
|
// ManagerOptions bundles options for the Manager.
|
|
|
@ -341,10 +342,16 @@ func NewManager(o *ManagerOptions) *Manager { |
|
|
|
manager := &Manager{ |
|
|
|
manager := &Manager{ |
|
|
|
groups: map[string]*Group{}, |
|
|
|
groups: map[string]*Group{}, |
|
|
|
opts: o, |
|
|
|
opts: o, |
|
|
|
|
|
|
|
block: make(chan struct{}), |
|
|
|
} |
|
|
|
} |
|
|
|
return manager |
|
|
|
return manager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Run starts processing of the rule manager.
|
|
|
|
|
|
|
|
func (m *Manager) Run() { |
|
|
|
|
|
|
|
close(m.block) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Stop the rule manager's rule evaluation cycles.
|
|
|
|
// Stop the rule manager's rule evaluation cycles.
|
|
|
|
func (m *Manager) Stop() { |
|
|
|
func (m *Manager) Stop() { |
|
|
|
log.Info("Stopping rule manager...") |
|
|
|
log.Info("Stopping rule manager...") |
|
|
@ -398,7 +405,13 @@ func (m *Manager) ApplyConfig(conf *config.Config) bool { |
|
|
|
oldg.stop() |
|
|
|
oldg.stop() |
|
|
|
newg.copyState(oldg) |
|
|
|
newg.copyState(oldg) |
|
|
|
} |
|
|
|
} |
|
|
|
go newg.run() |
|
|
|
go func() { |
|
|
|
|
|
|
|
// Wait with starting evaluation until the rule manager
|
|
|
|
|
|
|
|
// is told to run. This is necessary to avoid running
|
|
|
|
|
|
|
|
// queries against a bootstrapping storage.
|
|
|
|
|
|
|
|
<-m.block |
|
|
|
|
|
|
|
newg.run() |
|
|
|
|
|
|
|
}() |
|
|
|
wg.Done() |
|
|
|
wg.Done() |
|
|
|
}(newg) |
|
|
|
}(newg) |
|
|
|
} |
|
|
|
} |
|
|
|