creamqueue

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: AGPL-3.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobData

type JobData struct {
	URL  string
	Tags []string

	ParentPlaylistID        string
	ParentPlaylistExtractor string
}

JobData contains the arguments to begin processing our job

type JobFailure

type JobFailure struct {
	Error error
}

JobFailure is the reason why we couldn't process a job

type JobID

type JobID string

JobID is a unique identifier for a job

type JobProgress added in v0.0.3

type JobProgress string

JobProgress describes the current state of the job

type JobResult

type JobResult struct {
	Title     string
	CreamyURL string
}

JobResult is the output data of successfully processing a job

type OnFailedHandler

type OnFailedHandler func(id JobID, data JobData, failures []JobFailure)

An OnFailedHandler is called when a job is unable to finish successfully

type OnFinishedHandler

type OnFinishedHandler func(id JobID, data JobData, result JobResult)

An OnFinishedHandler is called when a job finishes successfully

type OnProgressHandler added in v0.0.3

type OnProgressHandler func(id JobID, data JobData, progress JobProgress)

An OnProgressHandler is called every time a job progresses

type OnQueuedHandler

type OnQueuedHandler func(id JobID, data JobData)

An OnQueuedHandler is called when a job is pushed to the queue

type OnStartedHandler

type OnStartedHandler func(id JobID, data JobData)

An OnStartedHandler is called when a job is started for the first time

type Queue

type Queue interface {
	OnQueued(handler OnQueuedHandler)
	OnStarted(handler OnStartedHandler)
	OnProgress(handler OnProgressHandler)
	OnFinished(handler OnFinishedHandler)
	OnFailed(handler OnFailedHandler)

	Push(id JobID, data JobData)
	Pull(ctx context.Context) QueuedJob
}

A Queue handles your jobs

func MakeBarebonesQueue

func MakeBarebonesQueue() Queue

MakeBarebonesQueue returns a perfectly valid and working Queue instance :^)

type QueuedJob

type QueuedJob interface {
	ID() JobID
	Data() *JobData

	Progress(progress JobProgress)
	Finished(result *JobResult)
	Failed(failure *JobFailure)
}

A QueuedJob is something we have to do... eventually

Jump to

Keyboard shortcuts

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