Finalize reliability configs

This commit is contained in:
Ben Sarmiento
2023-11-28 01:11:55 +01:00
parent a7fd68b3fd
commit 1f91d70420
3 changed files with 12 additions and 1 deletions

View File

@@ -7,8 +7,10 @@ host: "[::]" # do not change this if you are running it inside a docker containe
port: 9999 # do not change this if you are running it inside a docker container
concurrent_workers: 200
check_for_changes_every_secs: 15
# reliability configs
unrestrict_workers: 10 # since unrestricting has a different rate limit, use a different worker pool. decrease this if you are getting 429s
release_unrestrict_after_ms: 100 # wait time for every unrestrict worker to be released. increase this if you are getting 429s
rate_limit_sleep_secs: 6 # wait time after getting a 429 from Real-Debrid API
enable_repair: true # BEWARE! THERE CAN ONLY BE 1 INSTANCE OF ZURG THAT SHOULD REPAIR YOUR TORRENTS
retain_folder_name_extension: false # if true, zurg won't modify the filenames from real-debrid

View File

@@ -22,6 +22,7 @@ type ConfigInterface interface {
ShouldForceIPv6() bool
GetUnrestrictWorkers() int
GetReleaseUnrestrictAfterMs() int
GetRateLimitSleepSeconds() int
}
type ZurgConfig struct {
@@ -32,6 +33,7 @@ type ZurgConfig struct {
NumOfWorkers int `yaml:"concurrent_workers"`
UnrestrictWorkers int `yaml:"unrestrict_workers"`
ReleaseUnrestrictAfterMs int `yaml:"release_unrestrict_after_ms"`
RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs"`
RefreshEverySeconds int `yaml:"check_for_changes_every_secs"`
CanRepair bool `yaml:"enable_repair"`
OnLibraryUpdate string `yaml:"on_library_update"`
@@ -135,3 +137,10 @@ func (z *ZurgConfig) GetReleaseUnrestrictAfterMs() int {
}
return z.ReleaseUnrestrictAfterMs
}
func (z *ZurgConfig) GetRateLimitSleepSeconds() int {
if z.RateLimitSleepSeconds == 0 {
return 4
}
return z.RateLimitSleepSeconds
}

View File

@@ -80,7 +80,7 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
return resp, err
} else {
if val == 0 {
time.Sleep(8 * time.Second) // extra delay
time.Sleep(time.Duration(r.config.GetRateLimitSleepSeconds()) * time.Second) // extra delay
} else {
attempt += val
if attempt > r.MaxRetries {