Refactor torrent manager

This commit is contained in:
Ben Sarmiento
2023-11-09 02:34:04 +01:00
parent 9dfd6c32d5
commit 15a0ba95d8
14 changed files with 436 additions and 516 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/pkg/logutil"
"github.com/hashicorp/golang-lru/v2/expirable"
"github.com/nutsdb/nutsdb"
)
func main() {
@@ -25,9 +26,18 @@ func main() {
log.Panicf("Config failed to load: %v", configErr)
}
db, err := nutsdb.Open(
nutsdb.DefaultOptions,
nutsdb.WithDir("/tmp/nutsdb"),
)
if err != nil {
log.Fatal(err)
}
defer db.Close()
cache := expirable.NewLRU[string, string](1e4, nil, time.Hour)
torrentMgr := torrent.NewTorrentManager(config, cache)
torrentMgr := torrent.NewTorrentManager(config, cache, db)
mux := http.NewServeMux()
net.Router(mux, config, torrentMgr, cache)