Return a function that fails starting from failAfter times
(failAfter int32, delay time.Duration)
| 92 | |
| 93 | // Return a function that fails starting from failAfter times |
| 94 | func failingFunctionAfter(failAfter int32, delay time.Duration) func(context.Context, *InstanceDesc) (any, error) { |
| 95 | count := atomic.NewInt32(0) |
| 96 | return func(context.Context, *InstanceDesc) (any, error) { |
| 97 | time.Sleep(delay) |
| 98 | if count.Inc() > failAfter { |
| 99 | return nil, errFailure |
| 100 | } |
| 101 | return 1, nil |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func failingFunctionOnZones(zones ...string) func(context.Context, *InstanceDesc) (any, error) { |
| 106 | return func(ctx context.Context, ing *InstanceDesc) (any, error) { |
no test coverage detected