Help us shape the future of Go! Take the 2026 Go Developer Survey

tasks

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DeleteArchivedTaskType is the name of the task responsible for deleting
	// archived tasks from a task queue
	DeleteArchivedTaskType = "aux:task:delete-archived-tasks"
	// DeleteCompletedTaskType is the name of the task responsible for deleting
	// completed tasks from a task queue
	DeleteCompletedTaskType = "aux:task:delete-completed-tasks"
)
View Source
const (
	// CommandTaskType is the name of the task for executing external
	// commands.
	CommandTaskType = "aux:task:command"
)
View Source
const (
	// HousekeeperTaskType is the name of the task responsible for cleaning
	// up stale records from the database.
	HousekeeperTaskType = "aux:task:housekeeper"
)

Variables

View Source
var ErrNoCommand = errors.New("no command specified")

ErrNoCommand is an error which is returned when the task for executing external commands was called without specifying a command as part of the payload.

Functions

func HandleCommandTask

func HandleCommandTask(ctx context.Context, task *asynq.Task) error

HandleCommandTask executes the command specified as part of the payload.

func HandleDeleteArchivedTask

func HandleDeleteArchivedTask(ctx context.Context, task *asynq.Task) error

HandleDeleteArchivedTask deletes archived tasks.

func HandleDeleteCompletedTask

func HandleDeleteCompletedTask(ctx context.Context, task *asynq.Task) error

HandleDeleteCompletedTask deletes completed tasks.

func HandleHousekeeperTask

func HandleHousekeeperTask(ctx context.Context, task *asynq.Task) error

HandleHousekeeperTask performs housekeeping activities, such as deleting stale records.

Types

type CommandPayload

type CommandPayload struct {
	// Command specifies the path to the command to be executed
	Command string `yaml:"command" json:"command"`

	// Args specifies any optional arguments to be passed to the command.
	Args []string `yaml:"args" json:"args"`

	// Dir specifies the working directory of the command. If not specified
	// then the external command will be executed in the calling process'
	// current directory.
	Dir string `yaml:"dir" json:"dir"`
}

CommandPayload represents the payload of the task for executing external commands.

type DeleteQueuePayload

type DeleteQueuePayload struct {
	// Name of the queue that holds the tasks.
	Queue string `yaml:"queue" json:"queue"`
}

DeleteQueuePayload represents the payload of a task management task.

type HousekeeperPayload

type HousekeeperPayload struct {
	// Retention provides the retention configuration of objects.
	Retention []HousekeeperRetentionConfig `yaml:"retention" json:"retention"`
}

HousekeeperPayload represents the payload of the housekeeper task.

type HousekeeperRetentionConfig

type HousekeeperRetentionConfig struct {
	// Name specifies the model name.
	Name string `yaml:"name" json:"name"`

	// Duration specifies the max duration for which an object will be kept,
	// if it hasn't been updated recently.
	//
	// For example:
	//
	// UpdatedAt field for an object is set to: Thu May 30 16:00:00 EEST 2024
	// Duration of the object is configured to: 4 hours
	//
	// If the object is not update anymore by the time the housekeeper runs,
	// after 20:00:00 this object will be considered as stale and removed
	// from the database.
	Duration time.Duration `yaml:"duration" json:"duration"`
}

HousekeeperRetentionConfig represents the retention configuration for a given model.

Jump to

Keyboard shortcuts

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