Create torrent proto stub
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"homelab.lan/music-agregator/internal/config"
|
||||
"homelab.lan/music-agregator/internal/hello"
|
||||
"homelab.lan/music-agregator/internal/indexer"
|
||||
"homelab.lan/music-agregator/internal/torrent"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -94,12 +95,17 @@ func serveGrpc(config config.Config) {
|
||||
|
||||
indexerServer, err := indexer.NewIndexerServer(config)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Failed to create IndexerServer")
|
||||
log.Fatal().Err(err).Msg("failed to create IndexerServer")
|
||||
}
|
||||
torrentServer, err := torrent.NewTorrentServer(config)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("failed to create TorrentServer")
|
||||
}
|
||||
|
||||
services := []internal.Registrable{
|
||||
hello.NewHelloServer(),
|
||||
indexerServer,
|
||||
torrentServer,
|
||||
}
|
||||
|
||||
for _, service := range services {
|
||||
|
||||
@@ -1,23 +1,4 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: music-aggregator-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: music
|
||||
POSTGRES_PASSWORD: music
|
||||
POSTGRES_DB: music_aggregator
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||
ports:
|
||||
- "5433:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U music -d music_aggregator"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
jackett:
|
||||
image: lscr.io/linuxserver/jackett:latest
|
||||
container_name: music-aggregator-jackett
|
||||
@@ -52,11 +33,11 @@ services:
|
||||
- "6881:6881"
|
||||
- "6881:6881/udp"
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://localhost:9999"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 15s
|
||||
|
||||
qbittorrent:
|
||||
image: lscr.io/linuxserver/qbittorrent:latest
|
||||
@@ -76,7 +57,6 @@ services:
|
||||
- downloads:/downloads
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
jackett_config:
|
||||
jackett_downloads:
|
||||
qbittorrent_config:
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package torrent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pb "homelab.lan/music-agregator/gen/music_agregator/torrent/v1"
|
||||
"homelab.lan/music-agregator/internal/config"
|
||||
)
|
||||
|
||||
type TorrentServer struct {
|
||||
service *TorrentService
|
||||
pb.UnimplementedTorrentServiceServer
|
||||
}
|
||||
|
||||
func NewTorrentServer(cfg config.Config) (*TorrentServer, error) {
|
||||
service, err := NewIndexerService(cfg)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to initialize IndexerService")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &TorrentServer{service: service}, nil
|
||||
}
|
||||
|
||||
func (server *TorrentServer) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *TorrentServer) Register(server *grpc.Server) {
|
||||
pb.RegisterTorrentServiceServer(server, s)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package torrent
|
||||
|
||||
import "homelab.lan/music-agregator/internal/config"
|
||||
|
||||
type TorrentService struct {
|
||||
config config.Config
|
||||
}
|
||||
|
||||
func NewIndexerService(cfg config.Config) (*TorrentService, error) {
|
||||
return &TorrentService{config: cfg}, nil
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
syntax = "proto3";
|
||||
package music_agregator.torrent.v1;
|
||||
option go_package = "homelab.lan/music-agregator/gen/music_agregator/v1/torrent";
|
||||
|
||||
service TorrentService {
|
||||
rpc List(ListRequest) returns (ListResponse) {}
|
||||
}
|
||||
|
||||
message ListRequest {
|
||||
string client_name = 1;
|
||||
string filter = 2;
|
||||
string category = 3;
|
||||
string tag = 4;
|
||||
string sort = 5;
|
||||
bool reverse = 6;
|
||||
int32 limit = 7;
|
||||
int32 offset = 8;
|
||||
}
|
||||
|
||||
message ListResponse {
|
||||
repeated Torrent torrents = 1;
|
||||
}
|
||||
|
||||
message Torrent {
|
||||
string hash = 1;
|
||||
string name = 2;
|
||||
int64 size = 3;
|
||||
double progress = 4;
|
||||
int64 dlspeed = 5;
|
||||
int64 upspeed = 6;
|
||||
int32 num_seeds = 7;
|
||||
int32 num_leechs = 8;
|
||||
string state = 9;
|
||||
int64 eta = 10;
|
||||
double ratio = 11;
|
||||
string category = 12;
|
||||
string tags = 13;
|
||||
int64 added_on = 14;
|
||||
int64 completion_on = 15;
|
||||
string save_path = 16;
|
||||
string content_path = 17;
|
||||
int64 downloaded = 18;
|
||||
int64 uploaded = 19;
|
||||
string tracker = 20;
|
||||
int64 seeding_time = 21;
|
||||
int64 amount_left = 22;
|
||||
double availability = 23;
|
||||
}
|
||||
Reference in New Issue
Block a user