Documentation
¶
Overview ¶
Package task TODO: Doc: Common errors
Index ¶
- Constants
- Variables
- func NewProcessUploadTask(id uuid.UUID) *asynq.Task
- func NewPruneMediaTask(limit int64) *asynq.Task
- func NewPruneUploadsTask() *asynq.Task
- type Handler
- func (h *Handler) HandleProcessUploadTask(ctx context.Context, task *asynq.Task) error
- func (h *Handler) HandlePruneMediaTask(ctx context.Context, task *asynq.Task) error
- func (h *Handler) HandlePruneUploadsTask(_ context.Context, _ *asynq.Task) error
- func (h *Handler) ProcessTask(ctx context.Context, task *asynq.Task) error
Constants ¶
const TypeProcessUpload = "upload:process"
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.
const TypePruneUploads = "upload:prune"
Variables ¶
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 NewPruneMediaTask ¶
NewPruneMediaTask creates a new TypePruneMedia task. At most limit media records will be deleted when this task is executed.
func NewPruneUploadsTask ¶
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 (*Handler) HandlePruneMediaTask ¶
HandlePruneMediaTask handles TypePruneMedia tasks.