queue

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 FailureHandler

type FailureHandler interface {
	HandleDownloadFailed(ctx context.Context, g db.GrabHistory, clientError string) error
}

FailureHandler reacts to a grab whose download the client reported as failed (blocklist + re-search). Implemented by failedgrab.Handler.

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 PathMapper

type PathMapper interface {
	Map(ctx context.Context, clientID, path string) string
}

PathMapper rewrites a path reported by a download client into the path Pilot sees (remote path mappings). Implemented by remotepath.Service.

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.

func (*Service) SetFailureHandler

func (s *Service) SetFailureHandler(h FailureHandler)

SetFailureHandler installs the handler for failed downloads. Without one, failures are only logged.

func (*Service) SetPathMapper

func (s *Service) SetPathMapper(m PathMapper)

SetPathMapper installs the remote path mappings applied to the content path of completed downloads. Without one, paths are used as reported.

Jump to

Keyboard shortcuts

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