Use ants pool instead

This commit is contained in:
Ben Sarmiento
2023-11-18 20:50:14 +01:00
parent 44ec4a0b00
commit 6ef5b147c0
4 changed files with 44 additions and 23 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/debridmediamanager.com/zurg/internal/net"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/internal/version"
"github.com/panjf2000/ants/v2"
// zurghttp "github.com/debridmediamanager.com/zurg/pkg/http"
"github.com/debridmediamanager.com/zurg/pkg/logutil"
@@ -44,7 +45,13 @@ func main() {
rd := realdebrid.NewRealDebrid(config.GetToken(), logutil.NewLogger().Named("realdebrid"))
torrentMgr := torrent.NewTorrentManager(config, rd)
p, err := ants.NewPool(config.GetNumOfWorkers())
if err != nil {
log.Panicf("Failed to create ants pool: %v", err)
}
defer p.Release()
torrentMgr := torrent.NewTorrentManager(config, rd, p)
mux := http.NewServeMux()
net.Router(mux, config, torrentMgr, cache)