cron

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

func NewEngine

func NewEngine(handler JobHandler, maxConcurrent int) *Engine

func (*Engine) AddJob

func (e *Engine) AddJob(job *Job) error

func (*Engine) EnableJob

func (e *Engine) EnableJob(id string, enabled bool)

func (*Engine) ListJobs

func (e *Engine) ListJobs() []*Job

func (*Engine) MarshalJSON

func (e *Engine) MarshalJSON() ([]byte, error)

func (*Engine) RemoveJob

func (e *Engine) RemoveJob(id string)

func (*Engine) Start

func (e *Engine) Start()

func (*Engine) Status

func (e *Engine) Status() map[string]interface{}

func (*Engine) Stop

func (e *Engine) Stop()

type Job

type Job struct {
	ID                string        `json:"id"`
	Name              string        `json:"name"`
	Description       string        `json:"description,omitempty"`
	Enabled           bool          `json:"enabled"`
	Schedule          Schedule      `json:"schedule"`
	SessionTarget     SessionTarget `json:"session_target"`
	Payload           string        `json:"payload"`
	DeleteAfterRun    bool          `json:"delete_after_run,omitempty"`
	ConsecutiveErrors int           `json:"consecutive_errors"`
	LastRunAt         *time.Time    `json:"last_run_at,omitempty"`
	LastStatus        RunStatus     `json:"last_status,omitempty"`
	NextRunAt         *time.Time    `json:"next_run_at,omitempty"`
	MaxRetries        int           `json:"max_retries"`
	CreatedAt         time.Time     `json:"created_at"`
}

type JobHandler

type JobHandler func(job *Job) error

type RunRecord

type RunRecord struct {
	Timestamp  time.Time `json:"timestamp"`
	JobID      string    `json:"job_id"`
	Status     RunStatus `json:"status"`
	DurationMs int64     `json:"duration_ms"`
	Error      string    `json:"error,omitempty"`
}

type RunStatus

type RunStatus string
const (
	StatusOK      RunStatus = "ok"
	StatusError   RunStatus = "error"
	StatusSkipped RunStatus = "skipped"
)

type Schedule

type Schedule struct {
	Kind  ScheduleKind  `json:"kind"`
	At    *time.Time    `json:"at,omitempty"`
	Every time.Duration `json:"every,omitempty"`
}

type ScheduleKind

type ScheduleKind string
const (
	ScheduleAt    ScheduleKind = "at"
	ScheduleEvery ScheduleKind = "every"
)

type SessionTarget

type SessionTarget string
const (
	SessionMain     SessionTarget = "main"
	SessionIsolated SessionTarget = "isolated"
)

Jump to

Keyboard shortcuts

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