| 931 | } |
| 932 | |
| 933 | func WaitForConditionWithOptions(ctx context.Context, successFunc func() bool, maxNumAttempts, timeToSleepMs int) error { |
| 934 | waitForSuccess := func() (shouldRetry bool, err error, value interface{}) { |
| 935 | if successFunc() { |
| 936 | return false, nil, nil |
| 937 | } |
| 938 | return true, nil, nil |
| 939 | } |
| 940 | |
| 941 | sleeper := base.CreateSleeperFunc(maxNumAttempts, timeToSleepMs) |
| 942 | err, _ := base.RetryLoop(ctx, "Wait for condition options", waitForSuccess, sleeper) |
| 943 | if err != nil { |
| 944 | return err |
| 945 | } |
| 946 | |
| 947 | return nil |
| 948 | } |
| 949 | |
| 950 | func (rt *RestTester) WaitForConditionShouldRetry(conditionFunc func() (shouldRetry bool, err error, value interface{}), maxNumAttempts, timeToSleepMs int) error { |
| 951 | sleeper := base.CreateSleeperFunc(maxNumAttempts, timeToSleepMs) |