eitherContext returns a context that is canceled when either context ends.
(a, b context.Context)
| 2380 | |
| 2381 | // eitherContext returns a context that is canceled when either context ends. |
| 2382 | func eitherContext(a, b context.Context) context.Context { |
| 2383 | ctx, cancel := context.WithCancel(a) |
| 2384 | go func() { |
| 2385 | defer cancel() |
| 2386 | select { |
| 2387 | case <-a.Done(): |
| 2388 | case <-b.Done(): |
| 2389 | } |
| 2390 | }() |
| 2391 | return ctx |
| 2392 | } |
| 2393 | |
| 2394 | type gracefulShutdownBehavior int |
| 2395 |
no test coverage detected