When making API calls to third-party services, we may want to enforce timeouts and retry mechanisms.
In this example, the API call is set to retry a maximum of two times in case of failure, and the entire operation will be interrupted if it takes longer than 4 seconds.
Implementing Conditional Retries
Sometimes, we need to retry a failed API call only for specific error conditions, such as certain HTTP status codes.
Running Scheduled Effects Until Completion
Sometimes, we need to run a task periodically until a longer-running task completes. This is common in scenarios like polling or periodic status logging.