MCPcopy Create free account
hub / github.com/cortexproject/cortex / failingFunctionAfter

Function failingFunctionAfter

pkg/ring/replication_set_test.go:94–103  ·  view source on GitHub ↗

Return a function that fails starting from failAfter times

(failAfter int32, delay time.Duration)

Source from the content-addressed store, hash-verified

92
93// Return a function that fails starting from failAfter times
94func 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
105func failingFunctionOnZones(zones ...string) func(context.Context, *InstanceDesc) (any, error) {
106 return func(ctx context.Context, ing *InstanceDesc) (any, error) {

Callers 1

TestReplicationSet_DoFunction · 0.85

Calls 1

IncMethod · 0.45

Tested by

no test coverage detected