Documentation
¶
Overview ¶
Package queue tracks active downloads and synchronises their status with the download clients.
Index ¶
- type DownloaderClient
- type FailureHandler
- type Item
- type PathMapper
- type Service
- func (s *Service) GetQueue(ctx context.Context) ([]Item, error)
- func (s *Service) GetQueueItem(ctx context.Context, grabID string) (Item, error)
- func (s *Service) PollAndUpdate(ctx context.Context) error
- func (s *Service) RemoveFromQueue(ctx context.Context, grabID string, deleteFiles bool) error
- func (s *Service) SetFailureHandler(h FailureHandler)
- func (s *Service) SetPathMapper(m PathMapper)
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 ¶
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 ¶
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 ¶
GetQueueItem returns a single active queue item by its grab ID. Returns an error if the item is not found.
func (*Service) PollAndUpdate ¶
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 ¶
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.