runner

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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.

func (*Runner) Start

func (r *Runner) Start(ctx context.Context) error

Start begins executing scheduled tasks.

func (*Runner) Stop

func (r *Runner) Stop()

Stop gracefully shuts down the 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.

Directories

Path Synopsis
Package tasks provides background task implementations for the runner.
Package tasks provides background task implementations for the runner.

Jump to

Keyboard shortcuts

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