Share single torrent client across all services, eliminate triple qBittorrent login on startup

This commit is contained in:
Alexander
2026-05-09 21:42:53 +02:00
parent 758a4b909a
commit ef75b9bfba
5 changed files with 19 additions and 46 deletions
+2 -9
View File
@@ -7,7 +7,6 @@ import (
"google.golang.org/grpc"
pb "homelab.lan/music-agregator/gen/music_agregator/torrent/v1"
"homelab.lan/music-agregator/internal/config"
)
type TorrentServer struct {
@@ -15,14 +14,8 @@ type TorrentServer struct {
pb.UnimplementedTorrentServiceServer
}
func NewTorrentServer(cfg config.Config) (*TorrentServer, error) {
service, err := NewTorrentService(cfg)
if err != nil {
log.Err(err).Msg("failed to initialize TorrentService")
return nil, err
}
return &TorrentServer{service: service}, nil
func NewTorrentServer(client TorrentClient) *TorrentServer {
return &TorrentServer{service: NewTorrentService(client)}
}
func (server *TorrentServer) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, error) {