queue

package
v0.0.0-...-d771ed5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package queue tracks active downloads and synchronises their status with the download clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloaderClient

type DownloaderClient interface {
	ClientFor(ctx context.Context, configID string) (plugin.DownloadClient, error)
}

DownloaderClient is the minimal interface the queue service needs from the downloader service — just enough to talk to specific clients.

type Item

type Item struct {
	GrabID           string
	SeriesID         string
	EpisodeID        string // empty for season-pack grabs
	ReleaseTitle     string
	Protocol         string
	Size             int64
	DownloadedBytes  int64
	Status           string
	ClientItemID     string
	DownloadClientID string
	GrabbedAt        time.Time
}

Item is the queue-service view of an active download, enriching the raw plugin.QueueItem with grab_history context.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service polls download clients and keeps grab_history status up to date.

func NewService

func NewService(q db.Querier, downloader DownloaderClient, bus *events.Bus, logger *slog.Logger) *Service

NewService creates a new queue Service.

func (*Service) GetQueue

func (s *Service) GetQueue(ctx context.Context) ([]Item, error)

GetQueue returns all active downloads (those with a client_item_id that are not yet completed, failed, or removed) using the status cached in grab_history.

func (*Service) GetQueueItem

func (s *Service) GetQueueItem(ctx context.Context, grabID string) (Item, error)

GetQueueItem returns a single active queue item by its grab ID. Returns an error if the item is not found.

func (*Service) PollAndUpdate

func (s *Service) PollAndUpdate(ctx context.Context) error

PollAndUpdate fetches the current status of every active download from its download client and updates grab_history. Fires events for transitions to completed or failed.

func (*Service) RemoveFromQueue

func (s *Service) RemoveFromQueue(ctx context.Context, grabID string, deleteFiles bool) error

RemoveFromQueue removes a download from the client and marks the grab as removed. If deleteFiles is true the downloaded data is also deleted on disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL