{"modulePath":"github.com/beacon-stack/pilot","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queue\n\nPackage queue tracks active downloads and synchronises their status with the download clients.\n\n## Types\n\n```go\ntype DownloaderClient interface {\n\tClientFor(ctx context.Context, configID string) (plugin.DownloadClient, error)\n}\n```\nDownloaderClient is the minimal interface the queue service needs from the downloader service — just enough to talk to specific clients.\n\n```go\ntype FailureHandler interface {\n\tHandleDownloadFailed(ctx context.Context, g db.GrabHistory, clientError string) error\n}\n```\nFailureHandler reacts to a grab whose download the client reported as failed (blocklist + re-search). Implemented by failedgrab.Handler.\n\n```go\ntype Item struct {\n\tGrabID           string\n\tSeriesID         string\n\tEpisodeID        string // empty for season-pack grabs\n\tReleaseTitle     string\n\tProtocol         string\n\tSize             int64\n\tDownloadedBytes  int64\n\tStatus           string\n\tClientItemID     string\n\tDownloadClientID string\n\tGrabbedAt        time.Time\n}\n```\nItem is the queue-service view of an active download, enriching the raw plugin.QueueItem with grab\\_history context.\n\n```go\ntype PathMapper interface {\n\tMap(ctx context.Context, clientID, path string) string\n}\n```\nPathMapper rewrites a path reported by a download client into the path Pilot sees (remote path mappings). Implemented by remotepath.Service.\n\n```go\ntype Service struct {\n\t// contains filtered or unexported fields\n}\n```\nService polls download clients and keeps grab\\_history status up to date.\n\n```go\nfunc NewService(q db.Querier, downloader DownloaderClient, bus *events.Bus, logger *slog.Logger) *Service\n```\nNewService creates a new queue Service.\n\n```go\nfunc (s *Service) GetQueue(ctx context.Context) ([]Item, error)\n```\nGetQueue 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.\n\n```go\nfunc (s *Service) GetQueueItem(ctx context.Context, grabID string) (Item, error)\n```\nGetQueueItem returns a single active queue item by its grab ID. Returns an error if the item is not found.\n\n```go\nfunc (s *Service) PollAndUpdate(ctx context.Context) error\n```\nPollAndUpdate fetches the current status of every active download from its download client and updates grab\\_history. Fires events for transitions to completed or failed.\n\n```go\nfunc (s *Service) RemoveFromQueue(ctx context.Context, grabID string, deleteFiles bool) error\n```\nRemoveFromQueue removes a download from the client and marks the grab as removed. If deleteFiles is true the downloaded data is also deleted on disk.\n\n```go\nfunc (s *Service) SetFailureHandler(h FailureHandler)\n```\nSetFailureHandler installs the handler for failed downloads. Without one, failures are only logged.\n\n```go\nfunc (s *Service) SetPathMapper(m PathMapper)\n```\nSetPathMapper installs the remote path mappings applied to the content path of completed downloads. Without one, paths are used as reported.\n\n","path":"github.com/beacon-stack/pilot/internal/core/queue","name":"queue","synopsis":"Package queue tracks active downloads and synchronises their status with the download clients.","isRedistributable":true}
