schedule

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scheduler

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

Scheduler manages scheduled tasks

func NewScheduler

func NewScheduler() *Scheduler

NewScheduler creates a new scheduler

func (*Scheduler) Add

func (s *Scheduler) Add(task *Task)

Add adds a task to the scheduler

func (*Scheduler) Cron

func (s *Scheduler) Cron(expression string, name string, handler TaskHandler)

Cron schedules a task using cron expression

func (*Scheduler) Daily

func (s *Scheduler) Daily(timeStr string, name string, handler TaskHandler)

Daily schedules a task to run daily at specific time (HH:MM format)

func (*Scheduler) Every

func (s *Scheduler) Every(duration time.Duration, name string, handler TaskHandler)

Every schedules a task to run at fixed intervals

func (*Scheduler) Hourly

func (s *Scheduler) Hourly(minute int, name string, handler TaskHandler)

Hourly schedules a task to run every hour at specific minute

func (*Scheduler) List

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

List returns all scheduled tasks

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context)

Start starts the scheduler

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler

type Task

type Task struct {
	Name     string
	Schedule string // Cron expression or interval
	Handler  TaskHandler
	LastRun  time.Time
	NextRun  time.Time
	Enabled  bool
}

Task represents a scheduled task

type TaskHandler

type TaskHandler func(ctx context.Context) error

TaskHandler is a function that executes a scheduled task

Jump to

Keyboard shortcuts

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