Adjust config names to per minute

This commit is contained in:
Ben Adrian Sarmiento
2024-07-12 14:22:49 +02:00
parent fbc431b82b
commit 7f38e0535f
3 changed files with 15 additions and 15 deletions

View File

@@ -81,7 +81,7 @@ func MainApp(configPath string) {
}
}
rateLimiter := http.NewRateLimiter(config.GetAPIRateLimitPerSecond())
rateLimiter := http.NewRateLimiter(config.GetAPIRateLimitPerMinute())
apiClient := http.NewHTTPClient(
config.GetToken(),
@@ -127,7 +127,7 @@ func MainApp(configPath string) {
}
defer workerPool.Release()
torrentsRateLimiter := http.NewRateLimiter(config.GetTorrentsRateLimitPerSecond())
torrentsRateLimiter := http.NewRateLimiter(config.GetTorrentsRateLimitPerMinute())
rd := realdebrid.NewRealDebrid(
apiClient,

View File

@@ -10,7 +10,7 @@ type ConfigInterface interface {
EnableRepair() bool
EnableRetainFolderNameExtension() bool
EnableRetainRDTorrentName() bool
GetAPIRateLimitPerSecond() int
GetAPIRateLimitPerMinute() int
GetApiTimeoutSecs() int
GetConfig() ZurgConfig
GetDirectories() []string
@@ -31,7 +31,7 @@ type ConfigInterface interface {
GetRepairEveryMins() int
GetRetriesUntilFailed() int
GetToken() string
GetTorrentsRateLimitPerSecond() int
GetTorrentsRateLimitPerMinute() int
GetUsername() string
GetVersion() string
MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64, mediaInfos []*ffprobe.ProbeData) bool
@@ -48,7 +48,7 @@ type ZurgConfig struct {
Version string `yaml:"zurg" json:"-"`
Token string `yaml:"token" json:"-"`
APIRateLimitPerSecond int `yaml:"api_rate_limit_per_second" json:"api_rate_limit_per_second"`
APIRateLimitPerMinute int `yaml:"api_rate_limit_per_second" json:"api_rate_limit_per_second"`
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
AutoAnalyzeNewTorrents bool `yaml:"auto_analyze_new_torrents" json:"auto_analyze_new_torrents"`
CacheNetworkTestResults bool `yaml:"cache_network_test_results" json:"cache_network_test_results"`
@@ -76,7 +76,7 @@ type ZurgConfig struct {
RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"`
RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"`
ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
TorrentsRateLimitPerSecond int `yaml:"torrents_rate_limit_per_second" json:"torrents_rate_limit_per_second"`
TorrentsRateLimitPerMinute int `yaml:"torrents_rate_limit_per_second" json:"torrents_rate_limit_per_second"`
Username string `yaml:"username" json:"username"`
}
@@ -243,16 +243,16 @@ func (z *ZurgConfig) ShouldHideBrokenTorrents() bool {
return z.HideBrokenTorrents
}
func (z *ZurgConfig) GetAPIRateLimitPerSecond() int {
if z.APIRateLimitPerSecond == 0 {
func (z *ZurgConfig) GetAPIRateLimitPerMinute() int {
if z.APIRateLimitPerMinute == 0 {
return 250
}
return z.APIRateLimitPerSecond
return z.APIRateLimitPerMinute
}
func (z *ZurgConfig) GetTorrentsRateLimitPerSecond() int {
if z.TorrentsRateLimitPerSecond == 0 {
return 1
func (z *ZurgConfig) GetTorrentsRateLimitPerMinute() int {
if z.TorrentsRateLimitPerMinute == 0 {
return 60
}
return z.TorrentsRateLimitPerSecond
return z.TorrentsRateLimitPerMinute
}

View File

@@ -6,9 +6,9 @@ type RateLimiter struct {
ticker *time.Ticker
}
func NewRateLimiter(apiRateLimitPerSecond int) *RateLimiter {
func NewRateLimiter(rateLimitPerMinute int) *RateLimiter {
return &RateLimiter{
ticker: time.NewTicker(time.Second / time.Duration(apiRateLimitPerSecond)),
ticker: time.NewTicker(time.Minute / time.Duration(rateLimitPerMinute)),
}
}