()
| 28 | ) |
| 29 | |
| 30 | func counter() Circuit { |
| 31 | m := sync.Mutex{} |
| 32 | count := 0 |
| 33 | |
| 34 | // Service function. Fails after 5 tries. |
| 35 | return func(ctx context.Context) (string, error) { |
| 36 | m.Lock() |
| 37 | count++ |
| 38 | m.Unlock() |
| 39 | |
| 40 | return fmt.Sprintf("%d", count), nil |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // failAfter returns a function matching the Circuit type that returns an |
| 45 | // error after its been called more than threshold times. |
no outgoing calls
no test coverage detected