Documentation
¶
Index ¶
- Constants
- type AddOptions
- type CompletedItem
- type FileJob
- type PaginatedResult
- type PaginationParams
- type PendingArticleCheck
- type Queue
- func (q *Queue) AddFile(ctx context.Context, path string, size int64) error
- func (q *Queue) AddFileWithOptions(ctx context.Context, path string, size int64, opts AddOptions) error
- func (q *Queue) AddFileWithPriority(ctx context.Context, path string, size int64, priority int) error
- func (q *Queue) AddFileWithPriorityWithoutDuplicateCheck(ctx context.Context, path string, size int64, priority int) error
- func (q *Queue) AddFileWithoutDuplicateCheck(ctx context.Context, path string, size int64) error
- func (q *Queue) AddPendingArticleChecks(ctx context.Context, completedItemID string, articles []PendingArticleCheck) error
- func (q *Queue) CancelFile(ctx context.Context, msgID goqite.ID) error
- func (q *Queue) ClearCompletedItems() error
- func (q *Queue) ClearInProgress(ctx context.Context, msgID goqite.ID) error
- func (q *Queue) ClearQueue() error
- func (q *Queue) Close() error
- func (q *Queue) CompleteFile(ctx context.Context, msgID goqite.ID, nzbPath string, job *FileJob) error
- func (q *Queue) DB() *sql.DB
- func (q *Queue) DebugQueueItem(id string) (map[string]any, error)
- func (q *Queue) ExtendTimeout(ctx context.Context, msgID goqite.ID, duration time.Duration) error
- func (q *Queue) GetArticlesForCheck(ctx context.Context, limit int) ([]PendingArticleCheck, error)
- func (q *Queue) GetCompletedItemNzbPath(id string) (string, error)
- func (q *Queue) GetItemsForScriptRetry(ctx context.Context, limit int) ([]CompletedItem, error)
- func (q *Queue) GetPendingCheckCountForItem(ctx context.Context, completedItemID string) (total int, pending int, failed int, err error)
- func (q *Queue) GetQueueItems(params PaginationParams) (*PaginatedResult, error)
- func (q *Queue) GetQueueStats() (map[string]any, error)
- func (q *Queue) IsPathInQueue(path string) (bool, error)
- func (q *Queue) MarkArticleCheckFailed(ctx context.Context, id int64) error
- func (q *Queue) MarkArticleVerified(ctx context.Context, id int64) error
- func (q *Queue) MarkAsError(ctx context.Context, msgID goqite.ID, job *FileJob, errMsg string) error
- func (q *Queue) MarkScriptCompleted(ctx context.Context, itemID string) error
- func (q *Queue) MarkScriptFailed(ctx context.Context, itemID string, lastError string) error
- func (q *Queue) PendingTotalSize(ctx context.Context) (int64, error)
- func (q *Queue) ReaddJob(ctx context.Context, job *FileJob) error
- func (q *Queue) ReceiveFile(ctx context.Context) (*goqite.Message, *FileJob, error)
- func (q *Queue) RemoveCompletedItem(id string) error
- func (q *Queue) RemoveErroredItem(id string) error
- func (q *Queue) RemoveFromQueue(id string) error
- func (q *Queue) RetryErroredJob(ctx context.Context, id string) error
- func (q *Queue) SetQueueItemPriority(id string, priority int) error
- func (q *Queue) SetQueueItemPriorityWithReorder(ctx context.Context, id string, newPriority int) error
- func (q *Queue) UpdateArticleCheckRetry(ctx context.Context, id int64, retryCount int, nextRetryAt time.Time) error
- func (q *Queue) UpdateCompletedItemVerificationStatus(ctx context.Context, completedItemID string, status string) error
- func (q *Queue) UpdateScriptStatus(ctx context.Context, itemID string, status string, retryCount int, ...) error
- type QueueInterface
- type QueueItem
Constants ¶
const ( StatusPending = "pending" StatusRunning = "running" StatusComplete = "complete" StatusError = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddOptions ¶ added in v0.0.30
type AddOptions struct {
Priority int
InputFolder string // overrides processor's inferred root for relative-path → NZB output
DeleteOriginal *bool // overrides watcher.DeleteOriginalFile for this job only
}
AddOptions carries optional per-job fields when adding to the queue. Zero values preserve existing behavior; only the API entry point sets these today.
type CompletedItem ¶
type CompletedItem struct {
ID string `json:"id"`
Path string `json:"path"`
Size int64 `json:"size"`
Priority int `json:"priority"`
NzbPath string `json:"nzbPath"`
CreatedAt time.Time `json:"createdAt"`
CompletedAt time.Time `json:"completedAt"`
JobData []byte `json:"jobData"`
ScriptRetryCount int `json:"scriptRetryCount"` // Number of script retry attempts
ScriptFirstFailureAt *time.Time `json:"scriptFirstFailureAt"` // When the first script failure occurred
}
type FileJob ¶
type FileJob struct {
Path string `json:"path"`
Size int64 `json:"size"`
Priority int `json:"priority"`
CreatedAt time.Time `json:"createdAt"`
RetryCount int `json:"retryCount"`
// TransferID is a stable identifier assigned when the job is first created.
// It is carried through the persisted job body so it survives queue retries
// and crash recovery, letting the durable upload architecture reuse the same
// manifest and Message-IDs across attempts.
TransferID string `json:"transferId,omitempty"`
// InputFolder is the root directory used to derive the relative path
// for NZB output. When empty, the processor falls back to its existing
// inference (FOLDER: prefix → parent, watch folder match, or file dir).
InputFolder string `json:"inputFolder,omitempty"`
// DeleteOriginal optionally overrides the global delete-original setting
// for this specific job. nil → use the processor's default.
DeleteOriginal *bool `json:"deleteOriginal,omitempty"`
}
type PaginatedResult ¶ added in v0.0.26
type PaginatedResult struct {
Items []QueueItem `json:"items"`
TotalItems int `json:"totalItems"`
TotalPages int `json:"totalPages"`
CurrentPage int `json:"currentPage"`
ItemsPerPage int `json:"itemsPerPage"`
HasNext bool `json:"hasNext"`
HasPrev bool `json:"hasPrev"`
}
PaginatedResult contains paginated queue items and metadata
type PaginationParams ¶ added in v0.0.26
type PaginationParams struct {
Page int `json:"page"` // 1-based page number
Limit int `json:"limit"` // Items per page
SortBy string `json:"sortBy"` // Sort field: "created", "priority", "status", "filename", "size"
Order string `json:"order"` // Sort order: "asc", "desc"
Status string `json:"status"` // Status filter: "pending", "complete", "error", or "" for all
}
PaginationParams defines parameters for paginated queries
type PendingArticleCheck ¶ added in v0.0.29
type PendingArticleCheck struct {
ID int64
CompletedItemID string
MessageID string
Groups string // JSON-encoded array of group names
Status string // pending, verified, failed
RetryCount int
NextRetryAt time.Time
FirstFailureAt time.Time
LastCheckedAt *time.Time
CreatedAt time.Time
}
PendingArticleCheck represents an article that needs deferred verification
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
func (*Queue) AddFileWithOptions ¶ added in v0.0.30
func (q *Queue) AddFileWithOptions(ctx context.Context, path string, size int64, opts AddOptions) error
AddFileWithOptions adds a file to the queue with optional per-job overrides (priority, input folder for relative-path output, delete-original flag). Skips the add if the path is already tracked anywhere in the queue.
func (*Queue) AddFileWithPriority ¶
func (q *Queue) AddFileWithPriority(ctx context.Context, path string, size int64, priority int) error
AddFileWithPriority adds a file to the queue with a specific priority
func (*Queue) AddFileWithPriorityWithoutDuplicateCheck ¶
func (q *Queue) AddFileWithPriorityWithoutDuplicateCheck(ctx context.Context, path string, size int64, priority int) error
AddFileWithPriorityWithoutDuplicateCheck adds a file to the queue with a specific priority without checking for duplicates This is useful when original files are deleted after processing, making duplicate checks unnecessary
func (*Queue) AddFileWithoutDuplicateCheck ¶
AddFileWithoutDuplicateCheck adds a file to the queue without checking for duplicates This is useful when original files are deleted after processing, making duplicate checks unnecessary
func (*Queue) AddPendingArticleChecks ¶ added in v0.0.29
func (q *Queue) AddPendingArticleChecks(ctx context.Context, completedItemID string, articles []PendingArticleCheck) error
AddPendingArticleChecks inserts pending article checks for a completed item
func (*Queue) CancelFile ¶ added in v0.0.29
CancelFile removes a cancelled job from in-progress tracking.
func (*Queue) ClearCompletedItems ¶
ClearCompletedItems removes only completed items and their NZB files
func (*Queue) ClearInProgress ¶ added in v0.0.30
ClearInProgress removes the in-progress tracking row for the given message ID. Call this when a retry is about to be re-queued under a new ID, otherwise the old in_progress row leaks and the same path appears as duplicate UI entries across the pending goqite row and the stale in_progress row.
func (*Queue) ClearQueue ¶
ClearQueue removes all completed, errored, and active items from the queue
func (*Queue) CompleteFile ¶
func (q *Queue) CompleteFile(ctx context.Context, msgID goqite.ID, nzbPath string, job *FileJob) error
CompleteFile marks a file job as completed and adds it to completed_items table
func (*Queue) DB ¶ added in v0.0.30
DB returns the underlying database handle so adjacent stores (e.g. the durable transfer store) can share the same connection.
func (*Queue) DebugQueueItem ¶
DebugQueueItem returns debug information about a specific queue item
func (*Queue) ExtendTimeout ¶
ExtendTimeout extends the processing timeout for a file job
func (*Queue) GetArticlesForCheck ¶ added in v0.0.29
GetArticlesForCheck retrieves pending articles that are ready for checking
func (*Queue) GetCompletedItemNzbPath ¶
GetCompletedItemNzbPath returns the NZB path for a completed item
func (*Queue) GetItemsForScriptRetry ¶ added in v0.0.29
GetItemsForScriptRetry retrieves completed items that need script retry
func (*Queue) GetPendingCheckCountForItem ¶ added in v0.0.29
func (q *Queue) GetPendingCheckCountForItem(ctx context.Context, completedItemID string) (total int, pending int, failed int, err error)
GetPendingCheckCountForItem returns the total, pending, and failed count of article checks for a completed item
func (*Queue) GetQueueItems ¶
func (q *Queue) GetQueueItems(params PaginationParams) (*PaginatedResult, error)
GetQueueItems returns paginated queue items with metadata
func (*Queue) GetQueueStats ¶
GetQueueStats returns statistics about the queue including completed and errored items
func (*Queue) IsPathInQueue ¶ added in v0.0.17
IsPathInQueue checks if a file path already exists in pending queue, completed items, or errored items
func (*Queue) MarkArticleCheckFailed ¶ added in v0.0.29
MarkArticleCheckFailed marks a pending article check as permanently failed
func (*Queue) MarkArticleVerified ¶ added in v0.0.29
MarkArticleVerified marks a pending article check as verified
func (*Queue) MarkAsError ¶
func (q *Queue) MarkAsError(ctx context.Context, msgID goqite.ID, job *FileJob, errMsg string) error
MarkAsError marks a file job as errored and adds it to the errored_items table
func (*Queue) MarkScriptCompleted ¶ added in v0.0.29
MarkScriptCompleted marks the script execution as completed for a completed item
func (*Queue) MarkScriptFailed ¶ added in v0.0.29
MarkScriptFailed marks the script execution as permanently failed
func (*Queue) PendingTotalSize ¶ added in v0.0.30
PendingTotalSize returns the sum of pending FileJob sizes still queued in goqite. Used by the processor to gate pickup behind queue.min_size_to_start.
func (*Queue) ReceiveFile ¶
ReceiveFile gets the next file job from the queue and removes it immediately. The item is tracked in the in_progress_items table until CompleteFile or MarkAsError is called. On startup, RecoverInProgressItems restores any items that were lost due to a crash.
func (*Queue) RemoveCompletedItem ¶
RemoveCompletedItem removes a completed item and its associated NZB file
func (*Queue) RemoveErroredItem ¶
RemoveErroredItem removes an errored item from the database
func (*Queue) RemoveFromQueue ¶
RemoveFromQueue removes an item from the queue by ID (handles active, completed, and errored items)
func (*Queue) RetryErroredJob ¶
RetryErroredJob retries an errored job by moving it back to the main queue
func (*Queue) SetQueueItemPriority ¶
SetQueueItemPriority updates the priority of a pending queue item by id
func (*Queue) SetQueueItemPriorityWithReorder ¶ added in v0.0.13
func (q *Queue) SetQueueItemPriorityWithReorder(ctx context.Context, id string, newPriority int) error
SetQueueItemPriorityWithReorder updates the priority of a pending queue item using goqite's native priority Higher priority numbers (0, 1, 2, ...) are processed first
func (*Queue) UpdateArticleCheckRetry ¶ added in v0.0.29
func (q *Queue) UpdateArticleCheckRetry(ctx context.Context, id int64, retryCount int, nextRetryAt time.Time) error
UpdateArticleCheckRetry updates a pending article check for the next retry
func (*Queue) UpdateCompletedItemVerificationStatus ¶ added in v0.0.29
func (q *Queue) UpdateCompletedItemVerificationStatus(ctx context.Context, completedItemID string, status string) error
UpdateCompletedItemVerificationStatus updates the verification status of a completed item
func (*Queue) UpdateScriptStatus ¶ added in v0.0.29
func (q *Queue) UpdateScriptStatus(ctx context.Context, itemID string, status string, retryCount int, lastError string, nextRetryAt *time.Time, firstFailureAt *time.Time) error
UpdateScriptStatus updates the script execution status for a completed item. If firstFailureAt is provided and it's the first failure (retryCount == 1), it will be recorded.
type QueueInterface ¶ added in v0.0.13
type QueueInterface interface {
AddFile(ctx context.Context, path string, size int64) error
AddFileWithOptions(ctx context.Context, path string, size int64, opts AddOptions) error
GetQueueItems(params PaginationParams) (*PaginatedResult, error)
RemoveFromQueue(id string) error
ClearQueue() error
GetQueueStats() (map[string]any, error)
SetQueueItemPriorityWithReorder(ctx context.Context, id string, newPriority int) error
IsPathInQueue(path string) (bool, error)
PendingTotalSize(ctx context.Context) (int64, error)
}
QueueInterface defines the interface for queue operations
type QueueItem ¶
type QueueItem struct {
ID string `json:"id"`
Path string `json:"path"`
FileName string `json:"fileName"`
Size int64 `json:"size"`
Status string `json:"status"`
RetryCount int `json:"retryCount"`
Priority int `json:"priority"`
ErrorMessage *string `json:"errorMessage"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CompletedAt *time.Time `json:"completedAt"`
NzbPath *string `json:"nzbPath"`
// Script execution tracking fields
ScriptStatus *string `json:"scriptStatus"` // null, completed, pending_retry, failed_permanent
ScriptRetryCount int `json:"scriptRetryCount"`
ScriptLastError *string `json:"scriptLastError"`
ScriptNextRetryAt *time.Time `json:"scriptNextRetryAt"`
// Verification status for completed items (null for non-completed)
VerificationStatus *string `json:"verificationStatus"` // verified, pending_verification, verification_failed
}