add throttling to image download

This commit is contained in:
2024-01-24 18:35:06 +01:00
committed by T.v.Dein
parent de82127223
commit 8df3ebfa6d
4 changed files with 23 additions and 2 deletions

View File

@@ -20,9 +20,11 @@ package main
import (
"bytes"
"errors"
"math/rand"
"os"
"os/exec"
"runtime"
"time"
"github.com/mattn/go-isatty"
)
@@ -66,3 +68,7 @@ func IsNoTty() bool {
// it is a tty
return false
}
func GetThrottleTime() time.Duration {
return time.Duration(rand.Intn(MaxThrottle-MinThrottle+1)+MinThrottle) * time.Millisecond
}