Documentation
¶
Overview ¶
Package queue provides a simple job queue for processing media jobs.
Index ¶
- Constants
- type Job
- type JobHandler
- type JobStatus
- type JobType
- type Queue
- func (que *Queue) Cancel(id string) bool
- func (que *Queue) Delete(id string)
- func (que *Queue) Done() <-chan struct{}
- func (que *Queue) GetAllJobs() []*Job
- func (que *Queue) GetJob(id string) *Job
- func (que *Queue) Restore(job *Job)
- func (que *Queue) SetStatusFunc(fn StatusFunc)
- func (que *Queue) Start()
- func (que *Queue) Stop()
- func (que *Queue) Submit(job *Job)
- type StatusFunc
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 ¶
JobHandler is a function that handles jobs.
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) Done ¶
func (que *Queue) Done() <-chan struct{}
Done returns a channel that is closed when the queue is stopped.
func (*Queue) GetAllJobs ¶
GetAllJobs returns every job, newest first.
Jobs with the same CreatedAt are ordered by ID descending.
func (*Queue) SetStatusFunc ¶
func (que *Queue) SetStatusFunc(fn StatusFunc)
SetStatusFunc registers a callback invoked on job status changes.
type StatusFunc ¶
type StatusFunc func(job *Job)
StatusFunc is called whenever a job status changes.
Click to show internal directories.
Click to hide internal directories.