jobs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes added in v0.1.0

func RegisterRoutes(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware, broker *events.Broker, dlCache *downloadcache.Cache)

RegisterRoutes registers job routes on a group the server has already configured with authentication.

Types

type CreateJobPayload

type CreateJobPayload struct {
	Type      string      `json:"type" validate:"required,oneof=export scan bulk_download recompute_review" tstype:"JobType"`
	Data      interface{} `json:"data" validate:"required" tstype:"JobExportData | JobScanData | JobBulkDownloadData | JobRecomputeReviewData"`
	LibraryID *int        `json:"library_id,omitempty"`
}

type ListJobsOptions

type ListJobsOptions struct {
	Limit              *int
	Offset             *int
	Statuses           []string
	ProcessIDToExclude *string
	Type               *string
	LibraryIDOrGlobal  *int // Matches library_id = X OR library_id IS NULL
	// contains filtered or unexported fields
}

type ListJobsQuery

type ListJobsQuery struct {
	Limit             int      `query:"limit" json:"limit,omitempty" default:"10" validate:"min=1,max=100"`
	Offset            int      `query:"offset" json:"offset,omitempty" validate:"min=0"`
	Status            []string `query:"status" json:"status,omitempty" validate:"dive,oneof=pending in_progress completed failed" tstype:"JobStatus[]"`
	Type              *string  `query:"type" json:"type,omitempty" validate:"omitempty,oneof=export scan bulk_download recompute_review" tstype:"JobType"`
	LibraryIDOrGlobal *int     `query:"library_id_or_global" json:"library_id_or_global,omitempty"`
}

type ListJobsResponse added in v0.0.47

type ListJobsResponse struct {
	Items []*models.Job `json:"items" tstype:"Job[]"`
	Total int           `json:"total"`
}

ListJobsResponse is the GET /jobs list-endpoint envelope.

type RetrieveJobOptions

type RetrieveJobOptions struct {
	ID *int
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(db *bun.DB) *Service

func (*Service) CleanupOldJobs

func (svc *Service) CleanupOldJobs(ctx context.Context, retentionDays int) (int64, error)

CleanupOldJobs deletes completed and failed jobs older than the retention period. Associated job_logs are deleted automatically via ON DELETE CASCADE.

func (*Service) CreateJob

func (svc *Service) CreateJob(ctx context.Context, job *models.Job) error

func (*Service) HasActiveJob

func (svc *Service) HasActiveJob(ctx context.Context, jobType string, libraryID *int) (bool, error)

HasActiveJob checks if there's a pending or in-progress job of the given type. If libraryID is nil, checks for any active scan. If libraryID is set, checks for active scan with that library_id OR library_id IS NULL (global).

func (*Service) ListJobs

func (svc *Service) ListJobs(ctx context.Context, opts ListJobsOptions) ([]*models.Job, error)

func (*Service) ListJobsWithTotal

func (svc *Service) ListJobsWithTotal(ctx context.Context, opts ListJobsOptions) ([]*models.Job, int, error)

func (*Service) RetrieveJob

func (svc *Service) RetrieveJob(ctx context.Context, opts RetrieveJobOptions) (*models.Job, error)

func (*Service) UpdateJob

func (svc *Service) UpdateJob(ctx context.Context, job *models.Job, opts UpdateJobOptions) error

type UpdateJobOptions

type UpdateJobOptions struct {
	Columns []string
}

Jump to

Keyboard shortcuts

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