task

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package task provides storage operations for task management in the queue system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage handles database operations for tasks.

func NewStorage

func NewStorage(db *sqlx.DB) *Storage

NewStorage creates a new Storage instance with the provided database connection.

func (*Storage) AddTask

func (s *Storage) AddTask(ctx context.Context, task *entity.Task) error

AddTask inserts a new task into the database.

func (*Storage) CureTasks

func (s *Storage) CureTasks(
	ctx context.Context,
	taskType entity.TaskType,
	statuses []entity.TaskStatus,
	updatedAtTimeAgo time.Duration,
	comment string,
) ([]*entity.Task, error)

CureTasks updates stuck tasks to error status for retry.

func (*Storage) DeleteTasks

func (s *Storage) DeleteTasks(
	ctx context.Context,
	taskType entity.TaskType,
	statuses []entity.TaskStatus,
	updatedAtTimeAgo time.Duration,
) ([]*entity.Task, error)

DeleteTasks removes tasks with specified statuses that haven't been updated within the given time period.

func (*Storage) GetDB

func (s *Storage) GetDB() *sqlx.DB

GetDB returns the underlying database connection.

func (*Storage) GetTask

func (s *Storage) GetTask(ctx context.Context, id uuid.UUID) (*entity.Task, error)

GetTask retrieves a single task by its ID from the database.

func (*Storage) GetTasks

func (s *Storage) GetTasks(ctx context.Context, filter *dbentity.GetTasksFilter, limit int64) ([]*entity.Task, error)

GetTasks retrieves tasks matching the filter criteria with a specified limit.

func (*Storage) GetTasksForProcessing

func (s *Storage) GetTasksForProcessing(ctx context.Context, taskType entity.TaskType, limit int64) ([]*entity.Task, error)

GetTasksForProcessing retrieves and locks tasks ready for processing, updating their status to pending.

func (*Storage) HardUpdateTask

func (s *Storage) HardUpdateTask(ctx context.Context, taskID uuid.UUID, task *entity.Task) error

HardUpdateTask updates a task without automatically setting the updated_at timestamp.

func (*Storage) ResetAttempts added in v0.1.1

func (s *Storage) ResetAttempts(ctx context.Context, id uuid.UUID) error

ResetAttempts resets the retry attempts counter for a task and sets its status back to new.

func (*Storage) UpdateTask

func (s *Storage) UpdateTask(ctx context.Context, taskID uuid.UUID, task *entity.Task) error

UpdateTask updates an existing task in the database with the provided data.

Jump to

Keyboard shortcuts

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