Makes WaitForResult always return an error if it times out.

This commit is contained in:
James Phillips 2017-03-23 20:04:39 -07:00
parent 56b55b743f
commit 55b4446fbb
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 6 additions and 3 deletions

View File

@ -6,10 +6,10 @@ import (
"time"
"github.com/hashicorp/consul/consul/structs"
"github.com/pkg/errors"
)
type testFn func() (bool, error)
type errorFn func(error)
const (
baseWait = 1 * time.Millisecond
@ -33,8 +33,11 @@ func WaitForResult(try testFn) error {
wait = maxWait
}
}
return err
if err != nil {
return errors.Wrap(err, "timed out with error")
} else {
return fmt.Errorf("timed out")
}
}
type rpcFn func(string, interface{}, interface{}) error