scheduler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoTask means no pending task is ready for assignment.
	ErrNoTask = errors.New("no pending task")
	// ErrTaskNotFound means task ID is not known by scheduler.
	ErrTaskNotFound = errors.New("task not found")
	// ErrInvalidState means state transition is not allowed.
	ErrInvalidState = errors.New("invalid task state transition")
)

Functions

This section is empty.

Types

type RetryPolicy

type RetryPolicy struct {
	BaseDelay time.Duration
	MaxDelay  time.Duration
}

RetryPolicy controls task retry scheduling.

type Scheduler

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

Scheduler manages task queue and retry lifecycle.

func New

func New(retry RetryPolicy) *Scheduler

func (*Scheduler) Assign

func (s *Scheduler) Assign(workerID string) (*Task, error)

func (*Scheduler) Complete

func (s *Scheduler) Complete(taskID string) error

func (*Scheduler) Fail

func (s *Scheduler) Fail(taskID, errMsg string) error

func (*Scheduler) Snapshot

func (s *Scheduler) Snapshot() []Task

func (*Scheduler) Submit

func (s *Scheduler) Submit(task Task) error

type Task

type Task struct {
	ID        string
	JobID     string
	StageID   string
	Type      TaskType
	Payload   map[string]string
	State     TaskState
	WorkerID  string
	Attempt   int
	MaxRetry  int
	LastError string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Task is a minimal unit to schedule and retry.

type TaskState

type TaskState string

TaskState is the lifecycle state for one schedulable task.

const (
	TaskPending  TaskState = "pending"
	TaskRunning  TaskState = "running"
	TaskSuccess  TaskState = "success"
	TaskFailed   TaskState = "failed"
	TaskCanceled TaskState = "canceled"
)

type TaskType

type TaskType string

TaskType classifies task role in distributed execution.

const (
	TaskTypeMap    TaskType = "map"
	TaskTypeReduce TaskType = "reduce"
	TaskTypeOther  TaskType = "other"
)

Jump to

Keyboard shortcuts

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