Remove get torrents count config and use worker pool on all places

This commit is contained in:
Ben Adrian Sarmiento
2024-06-07 19:19:18 +02:00
parent ce2a56df2e
commit db086b19b3
9 changed files with 131 additions and 57 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/debridmediamanager/zurg/pkg/logutil"
"github.com/debridmediamanager/zurg/pkg/realdebrid"
"github.com/panjf2000/ants/v2"
)
const (
@@ -12,8 +13,8 @@ const (
MINIMUM_SLEEP = 60 // 60 seconds
)
func MonitorPremiumStatus(rd *realdebrid.RealDebrid, zurglog *logutil.Logger) {
go func() {
func MonitorPremiumStatus(workerPool *ants.Pool, rd *realdebrid.RealDebrid, zurglog *logutil.Logger) {
workerPool.Submit(func() {
for {
userInfo, err := rd.GetUserInformation()
if err != nil {
@@ -41,5 +42,5 @@ func MonitorPremiumStatus(rd *realdebrid.RealDebrid, zurglog *logutil.Logger) {
sleepDuration := time.Duration(remaining) * time.Second
time.Sleep(sleepDuration)
}
}()
})
}