Documentation
¶
Overview ¶
Package runner provides background task runner and lifecycle management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner manages and executes scheduled background tasks.
func NewRunner ¶
func NewRunner(registry *TaskRegistry) *Runner
NewRunner creates a new task runner.
type Task ¶
type Task interface {
// Name returns the unique name of the task
Name() string
// Schedule returns the cron schedule expression for this task
Schedule() string
// Run executes the task
Run(ctx context.Context) error
// Timeout returns the maximum time this task should run
Timeout() time.Duration
}
Task represents a background task that can be scheduled.
type TaskRegistry ¶
type TaskRegistry struct {
// contains filtered or unexported fields
}
TaskRegistry holds all registered tasks.
func NewTaskRegistry ¶
func NewTaskRegistry() *TaskRegistry
NewTaskRegistry creates a new task registry.
func (*TaskRegistry) All ¶
func (r *TaskRegistry) All() map[string]Task
All returns all registered tasks.
func (*TaskRegistry) Get ¶
func (r *TaskRegistry) Get(name string) (Task, bool)
Get returns a task by name.
func (*TaskRegistry) Register ¶
func (r *TaskRegistry) Register(task Task)
Register adds a task to the registry.
Click to show internal directories.
Click to hide internal directories.