Problem
How can I:
- Preserve responsiveness independent of downstream latency
- Stop waiting after a pre-determined period of time
- Take alternate action if timeout was reached
Solution
Allow only a specified period of time to elapse before a specified event is to take place, unless another specified event occurs first; in either case, the period is terminated when either event takes place.
For an example of practical application of timeout, see the CircuitBreaker stability pattern, first described by Michael Nygard.