converger: Add new timer system for determining convergence
This adds a new method of marking whether a particular UUID has converged or not. You can now Start, Stop, or Reset a convergence timer on the individual UUID's. This wraps the existing SetConverged calls with a hidden go routine. It is not recommended to use the SetConverged calls and the Timer calls on the same UUID.
This commit is contained in:
9
main.go
9
main.go
@@ -161,9 +161,12 @@ func run(c *cli.Context) error {
|
||||
// setup converger
|
||||
converger := NewConverger(
|
||||
c.Int("converged-timeout"),
|
||||
func() { // lambda to run when converged
|
||||
log.Printf("Converged for %d seconds, exiting!", c.Int("converged-timeout"))
|
||||
exit <- true // trigger an exit!
|
||||
func(b bool) error { // lambda to run when converged
|
||||
if b {
|
||||
log.Printf("Converged for %d seconds, exiting!", c.Int("converged-timeout"))
|
||||
exit <- true // trigger an exit!
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
go converger.Loop(true) // main loop for converger, true to start paused
|
||||
|
||||
Reference in New Issue
Block a user