schedule

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandTemplate

func ExpandTemplate(s string, t time.Time) string

ExpandTemplate replaces supported placeholders in s with the firing time t.

Supported placeholders:

{{date}}     -> 2006-01-02
{{datetime}} -> 2006-01-02 15:04
{{year}}     -> 2006
{{month}}    -> 01
{{day}}      -> 02
{{time}}     -> 15:04

Unknown placeholders are left untouched.

func FormatExample

func FormatExample(t time.Time) string

FormatExample renders a sample of every placeholder for the given time. Used in tests and as documentation.

func SupportedPlaceholders

func SupportedPlaceholders() []string

SupportedPlaceholders returns the list of supported placeholder tokens. Useful for surfacing to the UI as a hint.

Types

type Repository

type Repository interface {
	Create(ctx context.Context, s *Schedule) error
	Get(ctx context.Context, id string) (*Schedule, error)
	List(ctx context.Context, projectID string, limit, offset int) ([]*Schedule, int, error)
	// ListAll returns every schedule across all projects. Used by the scheduler
	// at server startup to register all enabled schedules.
	ListAll(ctx context.Context) ([]*Schedule, error)
	Update(ctx context.Context, s *Schedule) error
	Delete(ctx context.Context, id string) error
}

type Schedule

type Schedule struct {
	ID             string `yaml:"id"`
	ProjectID      string `yaml:"project_id"`
	WorkflowID     string `yaml:"workflow_id"`
	Name           string `yaml:"name"`
	Description    string `yaml:"description"`
	CronExpression string `yaml:"cron_expression"`
	Enabled        bool   `yaml:"enabled"`

	// Task content (template fields expanded at fire time).
	TaskTitle       string            `yaml:"task_title"`
	TaskDescription string            `yaml:"task_description"`
	StatusID        string            `yaml:"status_id,omitempty"`
	UseWorktree     bool              `yaml:"use_worktree"`
	Effort          string            `yaml:"effort,omitempty"`
	TaskMetadata    map[string]string `yaml:"task_metadata,omitempty"`

	// State updated by the scheduler.
	LastRunAt time.Time `yaml:"last_run_at,omitempty"`
	NextRunAt time.Time `yaml:"next_run_at,omitempty"`
	LastError string    `yaml:"last_error,omitempty"`

	CreatedAt time.Time `yaml:"created_at"`
	UpdatedAt time.Time `yaml:"updated_at"`
}

Schedule defines a cron-based recurring task creation.

type Scheduler

type Scheduler interface {
	// Add registers (or replaces) the schedule with the underlying cron runner.
	// Must be safe to call concurrently. Implementations should be a no-op when
	// the schedule is disabled, but it is the caller's responsibility to not
	// register disabled schedules.
	Add(s *Schedule) error
	// Update is equivalent to Add for an already-registered schedule. It removes
	// the existing entry then re-registers using the new cron expression.
	Update(s *Schedule) error
	// Remove unregisters the schedule. No-op if it was not registered.
	Remove(id string)
	// NextRun returns the next fire time for the given cron expression, or zero
	// time if the expression is invalid.
	NextRun(expr string, from time.Time) time.Time
}

Scheduler defines the behavior that schedule.Server requires from the in-process scheduler. The concrete implementation lives in internal/scheduler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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