INNER CODE UNIT · Go

uploadBackoffs

secureCodeBox/secureCodeBox · lurker/main.go:69

var uploadBackoffs = []time.Duration{1 * time.Second, 3 * time.Second, 5 * time.Second, 10 * time.Second, 30 * time.Second}

// indirection to allow tests to run without actually waiting
var sleep = time.Sleep

// uploadFileWithRetries uploads the file and retries network failures using the
// uploadBackoffs schedule.
func uploadFileWithRetries(path, url string) error {
	attempts := len(uploadBackoffs) + 1

	var err error
	for attempt := 1; attempt <= attempts; attempt++ {
		var retryable bool
		err, retryable = uploadFile(path, url)
		if err == nil {
			return nil
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…