Documentation
¶
Overview ¶
Package workqueue is the host's side of the media worker (media/worker): the River schema it drains in the host database, insert-only enqueueing and cancelling of its jobs, and processing progress for the read API. It needs neither ffmpeg nor libvips, so hosts that only presign, commit and read link it instead of the worker.
Index ¶
- Constants
- func ClearProgress(ctx context.Context, pool *pgxpool.Pool, id int64) error
- func Migrate(ctx context.Context, pool *pgxpool.Pool) error
- func NewProgressSource(pool *pgxpool.Pool) media.ProgressSource
- func RefMatch(ref contentref.ContentRef) ([]byte, *string, error)
- func SetProgress(ctx context.Context, pool *pgxpool.Pool, id int64, ...) error
- func VideoInsertOpts() *river.InsertOpts
- type ImageArgs
- type Queue
- type VideoArgs
Constants ¶
const ( Schema = "media_worker" ImageQueue = "media_image" // image variants, slots, inline images; placement of staged images VideoQueue = "media_video" // encodes; placement of staged videos MaxAttempts = 5 )
The worker's jobs live in their own River schema in the host database, so the heavy worker never joins (or wins leadership of) the host's River client.
Variables ¶
This section is empty.
Functions ¶
func ClearProgress ¶
ClearProgress drops a finished job's progress.
func Migrate ¶
Migrate creates Schema and applies River's migrations. Hosts run it in their migrate step; the worker also runs it at start.
func NewProgressSource ¶
func NewProgressSource(pool *pgxpool.Pool) media.ProgressSource
NewProgressSource reads encode progress from the worker's video jobs, for media.ReaderOptions.Progress. One indexed query per read of an item with a pending video.
func RefMatch ¶
func RefMatch(ref contentref.ContentRef) ([]byte, *string, error)
RefMatch is the jsonb containment and version a job query matches ref's jobs by.
func SetProgress ¶
func SetProgress(ctx context.Context, pool *pgxpool.Pool, id int64, files map[string]media.EncodeProgress) error
SetProgress records a running job's per-file progress (the worker's reports).
func VideoInsertOpts ¶
func VideoInsertOpts() *river.InsertOpts
VideoInsertOpts are a video job's insert options.
Types ¶
type ImageArgs ¶
type ImageArgs struct {
Ref contentref.ContentRef `json:"ref"`
Slot string `json:"slot,omitempty"`
After int64 `json:"after,omitempty"` // the running job this one follows
}
ImageArgs derives a ref's image variants, zip, slots and inline images, or one slot or inline image when Slot is set.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the host's insert-only client for the worker's jobs; it is the uploads' media.ProcessQueue.
func (*Queue) Cancel ¶
func (q *Queue) Cancel(ctx context.Context, ref contentref.ContentRef) (int, error)
Cancel cancels ref's queued and running image and video jobs, every stage: a running job's context is cancelled, so an encode is killed and publishes nothing further. It returns how many jobs it cancelled.
type VideoArgs ¶
type VideoArgs struct {
Ref contentref.ContentRef `json:"ref"`
}
VideoArgs encodes a manifest's video files.