(capacity int)
| 20 | } |
| 21 | |
| 22 | func newIdempotencyCache(capacity int) *idempotencyCache { |
| 23 | if capacity <= 0 { |
| 24 | capacity = defaultIdempotencyCapacity |
| 25 | } |
| 26 | return &idempotencyCache{ |
| 27 | capacity: capacity, |
| 28 | set: make(map[string]struct{}), |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // reserve records key and reports whether it had already been seen. The |
| 33 | // check-and-record is atomic so concurrent retries with the same key resolve |
no outgoing calls