task

package
v0.0.0-...-6d8caf4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package task TODO: Doc: Common errors

Index

Constants

View Source
const TypeProcessUpload = "upload:process"
View Source
const TypePruneMedia = "media:prune"

TypePruneMedia is the task type for the prune media task. This task detects and deletes media files that are not referenced by any songs. Deletion is permanent (i.e. not a soft-delete).

The payload of the task is a single int64 in varint encoding specifying the maximum number of media records to be deleted.

Only a single task of this type should be active at a time. Multiple active tasks will try to delete the same media records.

View Source
const TypePruneUploads = "upload:prune"

Variables

View Source
var (
	// ErrInvalidPayload indicates that the payload of a task did not correspond to the expected schema.
	// Tasks with this error will not be retried.
	ErrInvalidPayload = fmt.Errorf("invalid payload: %w", asynq.SkipRetry)
)

Functions

func NewProcessUploadTask

func NewProcessUploadTask(id uuid.UUID) *asynq.Task

func NewPruneMediaTask

func NewPruneMediaTask(limit int64) *asynq.Task

NewPruneMediaTask creates a new TypePruneMedia task. At most limit media records will be deleted when this task is executed.

func NewPruneUploadsTask

func NewPruneUploadsTask() *asynq.Task

Types

type Handler

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

Handler implements the asynq.Handler interface.

func NewHandler

func NewHandler(
	logger *slog.Logger,
	mediaRepo media.Repository,
	mediaService media.Service,
	uploadService upload.Service,
	uploadRepo upload.Repository,
	uploadStore upload.Store,
) *Handler

NewHandler creates a new Handler instance that can process tasks.

func (*Handler) HandleProcessUploadTask

func (h *Handler) HandleProcessUploadTask(ctx context.Context, task *asynq.Task) error

func (*Handler) HandlePruneMediaTask

func (h *Handler) HandlePruneMediaTask(ctx context.Context, task *asynq.Task) error

HandlePruneMediaTask handles TypePruneMedia tasks.

func (*Handler) HandlePruneUploadsTask

func (h *Handler) HandlePruneUploadsTask(_ context.Context, _ *asynq.Task) error

func (*Handler) ProcessTask

func (h *Handler) ProcessTask(ctx context.Context, task *asynq.Task) error

ProcessTask begins processing the specified task or returns an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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