tasks

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: GPL-3.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tasks provides task handling and execution functionality

Index

Constants

View Source
const (
	// TypeModelTransformation is the task type for model transformations
	TypeModelTransformation = "model:transformation"
)

Variables

View Source
var (
	// ErrModelConfigNotFound is returned when model configuration is not found
	ErrModelConfigNotFound = errors.New("model configuration not found")
	// ErrDependenciesNotSatisfied is returned when dependencies are not satisfied
	ErrDependenciesNotSatisfied = errors.New("dependencies not satisfied")
)

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Execute(ctx context.Context, taskCtx interface{}) error
	Validate(ctx context.Context, taskCtx interface{}) error
}

Executor defines the interface for task executors

type QueueManager

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

QueueManager manages task queuing

func NewQueueManager

func NewQueueManager(redisOpt *asynq.RedisClientOpt) *QueueManager

NewQueueManager creates a new queue manager

func (*QueueManager) Close

func (q *QueueManager) Close() error

Close closes the queue manager

func (*QueueManager) EnqueueTransformation

func (q *QueueManager) EnqueueTransformation(payload TaskPayload, opts ...asynq.Option) error

EnqueueTransformation enqueues a transformation task

func (*QueueManager) GetQueueStats

func (q *QueueManager) GetQueueStats(queueName string) (*asynq.QueueInfo, error)

GetQueueStats returns queue statistics

func (*QueueManager) IsTaskPendingOrRunning

func (q *QueueManager) IsTaskPendingOrRunning(task TaskPayload) (bool, error)

IsTaskPendingOrRunning checks if a task is pending or running

func (*QueueManager) WasRecentlyCompleted

func (q *QueueManager) WasRecentlyCompleted(task TaskPayload, within time.Duration) (bool, error)

WasRecentlyCompleted checks if a task was recently completed

type TaskContext

type TaskContext struct {
	Transformation models.Transformation
	Position       uint64
	Interval       uint64
	StartTime      time.Time
	Variables      map[string]interface{}
}

TaskContext contains all context needed for task execution

type TaskHandler

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

TaskHandler handles task execution

func NewTaskHandler

func NewTaskHandler(
	logger *logrus.Logger,
	chClient clickhouse.ClientInterface,
	adminService *admin.Service,
	validator *validation.DependencyValidator,
	modelExecutor Executor,
	transformations []models.Transformation,
) *TaskHandler

NewTaskHandler creates a new task handler

func (*TaskHandler) HandleTransformation

func (h *TaskHandler) HandleTransformation(ctx context.Context, t *asynq.Task) error

HandleTransformation handles transformation tasks

func (*TaskHandler) Routes

func (h *TaskHandler) Routes() map[string]asynq.HandlerFunc

Routes returns the task handler routes for Asynq

type TaskPayload

type TaskPayload struct {
	ModelID    string    `json:"model_id"`
	Position   uint64    `json:"position"`
	Interval   uint64    `json:"interval"`
	EnqueuedAt time.Time `json:"enqueued_at"`
}

TaskPayload represents the payload for a transformation task

func (TaskPayload) QueueName

func (p TaskPayload) QueueName() string

QueueName returns the queue name for this task payload

func (TaskPayload) UniqueID

func (p TaskPayload) UniqueID() string

UniqueID returns a unique identifier for this task

Jump to

Keyboard shortcuts

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