scheduler

package
v0.0.1-dev.12 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScheduledTask

type ScheduledTask struct {
	Task         worker.Task
	Interval     time.Duration
	NextRun      time.Time
	LastRun      time.Time
	IsActive     bool
	CronSchedule string
	CronEntryID  cron.EntryID
	MaxRuns      int // Maximum number of times the task should run
	CurrentRuns  int // Current number of times the task has run
}

ScheduledTask represents a task with scheduling information

type Scheduler

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

Scheduler manages scheduled tasks

func NewScheduler

func NewScheduler(config SchedulerConfig) (*Scheduler, error)

NewScheduler creates a new scheduler with the given configuration

func (*Scheduler) GetTaskStore

func (s *Scheduler) GetTaskStore() store.TaskStore

GetTaskStore returns the task store for external access

func (*Scheduler) List

func (s *Scheduler) List(ctx context.Context) []*ScheduledTask

List returns all scheduled tasks

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(task worker.Task, interval time.Duration, maxRuns int) error

Schedule schedules a task to run at the specified interval

func (*Scheduler) ScheduleCron

func (s *Scheduler) ScheduleCron(task worker.Task, cronExpr string, maxRuns int) error

ScheduleCron schedules a task to run based on a cron expression

func (*Scheduler) ScheduleInterval

func (s *Scheduler) ScheduleInterval(ctx context.Context, task worker.Task, interval time.Duration) error

ScheduleInterval schedules a task to run at the specified interval

func (*Scheduler) Start

func (s *Scheduler) Start()

Start starts the scheduler

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler

func (*Scheduler) Unschedule

func (s *Scheduler) Unschedule(ctx context.Context, taskID string) error

Unschedule removes a scheduled task

type SchedulerConfig

type SchedulerConfig struct {
	// Worker pool configuration
	WorkerPoolConfig pool.WorkerPoolConfig

	// Default schedule interval
	DefaultInterval time.Duration

	// Maximum number of scheduled tasks
	MaxTasks int

	// Task store for persistence
	TaskStore store.TaskStore

	// Enable persistence for scheduled tasks
	EnablePersistence bool
}

SchedulerConfig defines the configuration for a scheduler

Jump to

Keyboard shortcuts

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