f-79: agent: section times, renvoi de system_powerdown, attentes #79
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
8429dfd7e1
commit
8e89865418
13 changed files with 602 additions and 80 deletions
26
internal/dispatcher/agent/wait.go
Normal file
26
internal/dispatcher/agent/wait.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package dispatcher
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var errWaitTimeout = errors.New("timed out")
|
||||
|
||||
func waitUntil(timeout, poll time.Duration, done func() (bool, error)) error {
|
||||
deadline := time.After(timeout)
|
||||
for {
|
||||
ok, err := done()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ok {
|
||||
return nil
|
||||
}
|
||||
select {
|
||||
case <-deadline:
|
||||
return errWaitTimeout
|
||||
case <-time.After(poll):
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue