queue

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package queue provides a simple job queue for processing media jobs.

Index

Constants

View Source
const (
	// JobTypeClip represents a clip job.
	JobTypeClip JobType = "clip"

	// JobTypeGIF represents a GIF job.
	JobTypeGIF JobType = "gif"

	// JobTypeScreenshot represents a screenshot job.
	JobTypeScreenshot JobType = "screenshot"

	// JobStatusPending represents a pending job.
	JobStatusPending JobStatus = "pending"

	// JobStatusProcessing represents a processing job.
	JobStatusProcessing JobStatus = "processing"

	// JobStatusCompleted represents a completed job.
	JobStatusCompleted JobStatus = "completed"

	// JobStatusFailed represents a failed job.
	JobStatusFailed JobStatus = "failed"

	// JobStatusCancelled represents a job stopped by the user.
	JobStatusCancelled JobStatus = "canceled"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID            string
	Type          JobType
	Name          string
	MediaID       string
	MediaTitle    string
	MediaType     string
	InputPath     string
	OutputPath    string
	StartTime     float64
	Duration      float64
	Quality       string
	Width         int
	FPS           int
	AudioIndex    int
	CropBlackBars bool
	WebSafeColor  bool
	Status        JobStatus
	Progress      int
	Error         string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

Job represents a media processing job.

type JobHandler

type JobHandler func(ctx context.Context, job *Job) error

JobHandler is a function that handles jobs.

type JobStatus

type JobStatus string

JobStatus represents the status of a job.

type JobType

type JobType string

JobType represents the type of job.

type Queue

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

Queue represents a job queue.

func NewQueue

func NewQueue(workers int, handler JobHandler) *Queue

NewQueue creates a new job queue.

func (*Queue) Cancel

func (que *Queue) Cancel(id string) bool

Cancel stops a pending or processing job.

func (*Queue) Delete

func (que *Queue) Delete(id string)

Delete removes a job from the in-memory map.

func (*Queue) Done

func (que *Queue) Done() <-chan struct{}

Done returns a channel that is closed when the queue is stopped.

func (*Queue) GetAllJobs

func (que *Queue) GetAllJobs() []*Job

GetAllJobs returns every job, newest first.

Jobs with the same CreatedAt are ordered by ID descending.

func (*Queue) GetJob

func (que *Queue) GetJob(id string) *Job

GetJob gets a job by ID.

func (*Queue) Restore

func (que *Queue) Restore(job *Job)

Restore registers a job without enqueueing it.

func (*Queue) SetStatusFunc

func (que *Queue) SetStatusFunc(fn StatusFunc)

SetStatusFunc registers a callback invoked on job status changes.

func (*Queue) Start

func (que *Queue) Start()

Start starts the job queue workers.

func (*Queue) Stop

func (que *Queue) Stop()

Stop stops the job queue.

func (*Queue) Submit

func (que *Queue) Submit(job *Job)

Submit submits a job to the queue.

type StatusFunc

type StatusFunc func(job *Job)

StatusFunc is called whenever a job status changes.

Jump to

Keyboard shortcuts

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