scheduler

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: GPL-3.0 Imports: 7 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 interface {
	Start(ctx context.Context) error
	Stop() error
	AddTask(ctx context.Context, task *db.ScheduledTask) (int64, error)
	RemoveTask(ctx context.Context, taskID int64) error
	ListTasks(ctx context.Context, channelID string) ([]*db.ScheduledTask, error)
	SetTaskEnabled(ctx context.Context, taskID int64, enabled bool) error
	ToggleTask(ctx context.Context, taskID int64) (bool, error)
	EditTask(ctx context.Context, taskID int64, schedule, taskType, prompt *string) error
}

Scheduler manages scheduled tasks.

type TaskExecutor

type TaskExecutor interface {
	ExecuteTask(ctx context.Context, task *db.ScheduledTask) (string, error)
}

TaskExecutor executes a scheduled task and returns a response or error.

type TaskScheduler

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

TaskScheduler implements Scheduler using a polling loop.

func NewTaskScheduler

func NewTaskScheduler(store db.Store, executor TaskExecutor, pollInterval time.Duration, logger *slog.Logger) *TaskScheduler

NewTaskScheduler creates a new TaskScheduler.

func (*TaskScheduler) AddTask

func (s *TaskScheduler) AddTask(ctx context.Context, task *db.ScheduledTask) (int64, error)

AddTask calculates next_run_at, enables the task, and stores it.

func (*TaskScheduler) EditTask

func (s *TaskScheduler) EditTask(ctx context.Context, taskID int64, schedule, taskType, prompt *string) error

EditTask updates a scheduled task's schedule, type, and/or prompt.

func (*TaskScheduler) ListTasks

func (s *TaskScheduler) ListTasks(ctx context.Context, channelID string) ([]*db.ScheduledTask, error)

ListTasks returns all tasks for a channel.

func (*TaskScheduler) RemoveTask

func (s *TaskScheduler) RemoveTask(ctx context.Context, taskID int64) error

RemoveTask deletes a task from the store.

func (*TaskScheduler) SetTaskEnabled

func (s *TaskScheduler) SetTaskEnabled(ctx context.Context, taskID int64, enabled bool) error

SetTaskEnabled enables or disables a scheduled task.

func (*TaskScheduler) Start

func (s *TaskScheduler) Start(ctx context.Context) error

Start launches the polling loop in a background goroutine.

func (*TaskScheduler) Stop

func (s *TaskScheduler) Stop() error

Stop gracefully stops the polling loop and waits for it to finish.

func (*TaskScheduler) ToggleTask

func (s *TaskScheduler) ToggleTask(ctx context.Context, taskID int64) (bool, error)

ToggleTask flips a scheduled task's enabled state and returns the new state.

Jump to

Keyboard shortcuts

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