cron

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNextRun added in v0.4.8

func GetNextRun(schedule string) (*time.Time, error)

GetNextRun calculates the next run time for a schedule expression

func ValidateSchedule added in v0.4.8

func ValidateSchedule(schedule string) error

ValidateSchedule checks if a cron expression is valid

Types

type ExecutionLog added in v0.4.8

type ExecutionLog struct {
	ID         string     `json:"id"`
	JobID      string     `json:"job_id"`
	JobName    string     `json:"job_name"`
	StartedAt  time.Time  `json:"started_at"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
	Status     string     `json:"status"` // success, failed, timeout
	Output     string     `json:"output,omitempty"`
	Error      string     `json:"error,omitempty"`
	Duration   string     `json:"duration,omitempty"`
}

ExecutionLog records the result of a job execution

type Job

type Job struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Schedule    string                 `json:"schedule"`
	Prompt      string                 `json:"prompt"`
	Skills      []string               `json:"skills,omitempty"`
	Platform    string                 `json:"platform,omitempty"`
	Enabled     bool                   `json:"enabled"`
	NoAgent     bool                   `json:"no_agent"` // Skip agent, run script directly
	Script      string                 `json:"script"`   // Script/command for no_agent mode
	NextRun     *time.Time             `json:"next_run,omitempty"`
	LastRun     *time.Time             `json:"last_run,omitempty"`
	LastStatus  string                 `json:"last_status,omitempty"` // success, failed, running
	LastError   string                 `json:"last_error,omitempty"`
	RunCount    int                    `json:"run_count,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

Job represents a scheduled cron job

type Manager

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

Manager manages cron jobs with real scheduling

func NewManager

func NewManager() (*Manager, error)

NewManager creates a new cron manager

func (*Manager) Add

func (m *Manager) Add(job *Job) error

func (*Manager) ClearLogs added in v0.4.8

func (m *Manager) ClearLogs(jobID string) error

func (*Manager) Get

func (m *Manager) Get(name string) *Job

func (*Manager) GetByID added in v0.4.8

func (m *Manager) GetByID(id string) *Job

func (*Manager) GetDueJobs

func (m *Manager) GetDueJobs() []*Job

func (*Manager) GetLogs added in v0.4.8

func (m *Manager) GetLogs(jobID string, limit int) []ExecutionLog

func (*Manager) List

func (m *Manager) List() []*Job

func (*Manager) Remove

func (m *Manager) Remove(id string) error

func (*Manager) RunJob

func (m *Manager) RunJob(ctx context.Context, job *Job) error

RunJob manually triggers a job execution

func (*Manager) SetAgentDeps added in v0.4.8

func (m *Manager) SetAgentDeps(prov provider.Provider, reg *tool.Registry)

SetAgentDeps sets the agent dependencies (provider, tool registry)

func (*Manager) Start added in v0.4.8

func (m *Manager) Start()

Start begins the cron scheduler loop and loads all enabled jobs

func (*Manager) Stop added in v0.4.8

func (m *Manager) Stop()

Stop gracefully stops the cron scheduler

func (*Manager) Update

func (m *Manager) Update(job *Job) error

Jump to

Keyboard shortcuts

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