Created
August 12, 2021 21:35
-
-
Save dathanb/6d0f6eb083ee54b5e512763d2fa4eeb1 to your computer and use it in GitHub Desktop.
Retryable curl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try hard to make idempotent calls to services that are a little flaky | |
function retryableCurl() { | |
for i in `seq 1 5`; do | |
code="$(curl -s -o /dev/null -w "%{http_code}" "$@")" | |
if [[ $? -eq 0 && code -lt 300 && code -ge 200 ]]; then | |
return | |
fi | |
done | |
printf "Failed to curl with arguments $*\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment