retry

command module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 7 Imported by: 0

README

retry

The command for retrying commands.

Pass commands to retry with configurable backoff settings, allowing retry of operations whilst not overloading a system.

Use

retry [retry options] -- <command to retry>

It's advised to use -- before the command you would like to retry to differentiate retry options from the options of the command you are running. If your command requires no arguments, the -- can be omitted.

Retry options

      --initial-backoff duration   initial backoff duration. (default 1s)
      --max-attempts uint          upper limit of number of attempts. 0 indicates no limit.
      --max-backoff duration       upper limit of backoff duration. 0 indicates no limit.
      --multiplier float           multiplier to apply after each failed attempt. (default 2)
      --randomisation float        randomisation to apply to the multiplication of each backoff
  -v, --version                    print the version

Install

Installable assets available in the releases page or from the following package managers.

Homebrew

brew tap glynternet/glynternet
brew install retry

Snapstore (coming soon)

Example

Append to /tmp/lines once and fail script if less than three lines

$ cat ./run.sh 
#!/bin/bash
set -euf -o pipefail
date >> /tmp/lines
test "$(wc -l /tmp/lines)" = 3

Double the backoff time each iteration

$ retry --initial-backoff 1s --multiplier 2 ./run.sh && echo done
error:  exit status 1
error:  exit status 1
done

Result

$ cat /tmp/lines 
Sat 21 Oct 21:17:37 MDT 2023
Sat 21 Oct 21:17:38 MDT 2023
Sat 21 Oct 21:17:40 MDT 2023

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL