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:
James Shubin
2016-08-30 03:56:22 -04:00
parent 6d45cd45d1
commit eee652cefe
2 changed files with 75 additions and 3 deletions

View File

@@ -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