Documentation
¶
Index ¶
- Constants
- type CompletedItem
- type FileJob
- type GooseMigrationRunner
- func (gmr *GooseMigrationRunner) EnsureMigrationCompatibility() error
- func (gmr *GooseMigrationRunner) GetStatus() (*GooseMigrationStatus, error)
- func (gmr *GooseMigrationRunner) IsLegacyDatabase() (bool, error)
- func (gmr *GooseMigrationRunner) MigrateDown() error
- func (gmr *GooseMigrationRunner) MigrateTo(version int64) error
- func (gmr *GooseMigrationRunner) MigrateUp() error
- func (gmr *GooseMigrationRunner) RecreateDatabase() error
- func (gmr *GooseMigrationRunner) Reset() error
- func (gmr *GooseMigrationRunner) SetupGoose() error
- type GooseMigrationStatus
- type Queue
- func (q *Queue) AddFile(ctx context.Context, path string, size int64) 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) ClearCompletedItems() 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) DebugQueueItem(id string) (map[string]interface{}, error)
- func (q *Queue) EnsureMigrationCompatibility() error
- func (q *Queue) ExtendTimeout(ctx context.Context, msgID goqite.ID, duration time.Duration) error
- func (q *Queue) GetCompletedItemNzbPath(id string) (string, error)
- func (q *Queue) GetMigrationStatus() (*GooseMigrationStatus, error)
- func (q *Queue) GetQueueItems() ([]QueueItem, error)
- func (q *Queue) GetQueueStats() (map[string]interface{}, error)
- func (q *Queue) IsLegacyDatabase() (bool, error)
- func (q *Queue) IsPathInQueue(path string) (bool, error)
- func (q *Queue) MarkAsError(ctx context.Context, msgID goqite.ID, job *FileJob, errMsg string) error
- func (q *Queue) MigrateTo(version 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) RecreateDatabase() 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) ResetDatabase() error
- func (q *Queue) RetryErroredJob(ctx context.Context, id string) error
- func (q *Queue) RollbackMigration() error
- func (q *Queue) RunMigrations() error
- func (q *Queue) SetQueueItemPriority(id string, priority int) error
- func (q *Queue) SetQueueItemPriorityWithReorder(ctx context.Context, id string, newPriority 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 CompletedItem ¶
type GooseMigrationRunner ¶ added in v0.0.13
type GooseMigrationRunner struct {
// contains filtered or unexported fields
}
GooseMigrationRunner handles database migrations using goose
func NewGooseMigrationRunner ¶ added in v0.0.13
func NewGooseMigrationRunner(db *sql.DB) *GooseMigrationRunner
NewGooseMigrationRunner creates a new goose migration runner
func (*GooseMigrationRunner) EnsureMigrationCompatibility ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) EnsureMigrationCompatibility() error
EnsureMigrationCompatibility checks for legacy database and recreates if needed
func (*GooseMigrationRunner) GetStatus ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) GetStatus() (*GooseMigrationStatus, error)
GetStatus returns the current migration status
func (*GooseMigrationRunner) IsLegacyDatabase ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) IsLegacyDatabase() (bool, error)
IsLegacyDatabase checks if the database exists but doesn't have goose migrations table
func (*GooseMigrationRunner) MigrateDown ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) MigrateDown() error
MigrateDown rolls back the last migration
func (*GooseMigrationRunner) MigrateTo ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) MigrateTo(version int64) error
MigrateTo migrates to a specific version
func (*GooseMigrationRunner) MigrateUp ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) MigrateUp() error
MigrateUp runs all pending migrations
func (*GooseMigrationRunner) RecreateDatabase ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) RecreateDatabase() error
RecreateDatabase drops all existing tables and recreates them using goose migrations
func (*GooseMigrationRunner) Reset ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) Reset() error
Reset drops all tables and re-runs all migrations
func (*GooseMigrationRunner) SetupGoose ¶ added in v0.0.13
func (gmr *GooseMigrationRunner) SetupGoose() error
SetupGoose initializes goose with embedded migrations
type GooseMigrationStatus ¶ added in v0.0.13
type GooseMigrationStatus struct {
CurrentVersion int64 `json:"currentVersion"`
}
GooseMigrationStatus represents the current migration state using goose
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
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) ClearCompletedItems ¶
ClearCompletedItems removes only completed items and their NZB files
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) DebugQueueItem ¶
DebugQueueItem returns debug information about a specific queue item
func (*Queue) EnsureMigrationCompatibility ¶ added in v0.0.13
EnsureMigrationCompatibility ensures the database is compatible with goose migrations
func (*Queue) ExtendTimeout ¶
ExtendTimeout extends the processing timeout for a file job
func (*Queue) GetCompletedItemNzbPath ¶
GetCompletedItemNzbPath returns the NZB path for a completed item
func (*Queue) GetMigrationStatus ¶ added in v0.0.13
func (q *Queue) GetMigrationStatus() (*GooseMigrationStatus, error)
GetMigrationStatus returns the current migration status using goose
func (*Queue) GetQueueItems ¶
GetQueueItems returns queue items for display including completed items
func (*Queue) GetQueueStats ¶
GetQueueStats returns statistics about the queue including completed and errored items
func (*Queue) IsLegacyDatabase ¶ added in v0.0.13
IsLegacyDatabase checks if the database is a legacy (non-goose) database
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) 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) ReceiveFile ¶
ReceiveFile gets the next file job from the queue and removes it immediately
func (*Queue) RecreateDatabase ¶ added in v0.0.13
RecreateDatabase drops all tables and recreates them using goose migrations
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) ResetDatabase ¶ added in v0.0.13
ResetDatabase drops all tables and re-runs all migrations using goose
func (*Queue) RetryErroredJob ¶
RetryErroredJob retries an errored job by moving it back to the main queue
func (*Queue) RollbackMigration ¶ added in v0.0.13
RollbackMigration rolls back the last applied migration using goose
func (*Queue) RunMigrations ¶ added in v0.0.13
RunMigrations runs all pending migrations using goose
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
type QueueInterface ¶ added in v0.0.13
type QueueInterface interface {
AddFile(ctx context.Context, path string, size int64) error
GetQueueItems() ([]QueueItem, error)
RemoveFromQueue(id string) error
ClearQueue() error
GetQueueStats() (map[string]interface{}, error)
SetQueueItemPriorityWithReorder(ctx context.Context, id string, newPriority int) error
GetMigrationStatus() (*GooseMigrationStatus, error)
RunMigrations() error
RollbackMigration() error
MigrateTo(version int64) error
ResetDatabase() error
IsLegacyDatabase() (bool, error)
RecreateDatabase() error
EnsureMigrationCompatibility() error
IsPathInQueue(path string) (bool, 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"`
}