mirror of https://github.com/status-im/consul.git
Makes WaitForResult always return an error if it times out.
This commit is contained in:
parent
85c03852a4
commit
4e7064023f
|
@ -6,10 +6,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/consul/structs"
|
"github.com/hashicorp/consul/consul/structs"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testFn func() (bool, error)
|
type testFn func() (bool, error)
|
||||||
type errorFn func(error)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
baseWait = 1 * time.Millisecond
|
baseWait = 1 * time.Millisecond
|
||||||
|
@ -33,8 +33,11 @@ func WaitForResult(try testFn) error {
|
||||||
wait = maxWait
|
wait = maxWait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
return err
|
return errors.Wrap(err, "timed out with error")
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("timed out")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type rpcFn func(string, interface{}, interface{}) error
|
type rpcFn func(string, interface{}, interface{}) error
|
||||||
|
|
Loading…
Reference in New Issue