cron

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronJob

type CronJob struct {
	ID             string       `json:"id"`
	Name           string       `json:"name"`
	Enabled        bool         `json:"enabled"`
	Schedule       CronSchedule `json:"schedule"`
	Payload        CronPayload  `json:"payload"`
	State          CronJobState `json:"state"`
	CreatedAtMS    int64        `json:"createdAtMs"`
	UpdatedAtMS    int64        `json:"updatedAtMs"`
	DeleteAfterRun bool         `json:"deleteAfterRun"`
}

type CronJobState

type CronJobState struct {
	NextRunAtMS         *int64 `json:"nextRunAtMs,omitempty"`
	LastRunAtMS         *int64 `json:"lastRunAtMs,omitempty"`
	LastStatus          string `json:"lastStatus,omitempty"`
	LastError           string `json:"lastError,omitempty"`
	LastDurationMS      int64  `json:"lastDurationMs,omitempty"`
	LastScheduleDelayMS int64  `json:"lastScheduleDelayMs,omitempty"`
	TotalRuns           int64  `json:"totalRuns,omitempty"`
	TotalFailures       int64  `json:"totalFailures,omitempty"`
	ConsecutiveFailures int64  `json:"consecutiveFailures,omitempty"`
}

type CronPayload

type CronPayload struct {
	Kind    string `json:"kind"`
	Message string `json:"message"`
	Deliver bool   `json:"deliver"`
	Channel string `json:"channel,omitempty"`
	To      string `json:"to,omitempty"`
}

type CronSchedule

type CronSchedule struct {
	Kind    string `json:"kind"`
	AtMS    *int64 `json:"atMs,omitempty"`
	EveryMS *int64 `json:"everyMs,omitempty"`
	Expr    string `json:"expr,omitempty"`
	TZ      string `json:"tz,omitempty"`
}

type CronService

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

func NewCronService

func NewCronService(storePath string, onJob JobHandler) *CronService

func (*CronService) AddJob

func (cs *CronService) AddJob(name string, schedule CronSchedule, message string, deliver bool, channel, to string) (*CronJob, error)

func (*CronService) EnableJob

func (cs *CronService) EnableJob(jobID string, enabled bool) *CronJob

func (*CronService) GetJob

func (cs *CronService) GetJob(jobID string) *CronJob

func (*CronService) ListJobs

func (cs *CronService) ListJobs(includeDisabled bool) []CronJob

func (*CronService) Load

func (cs *CronService) Load() error

func (*CronService) RemoveJob

func (cs *CronService) RemoveJob(jobID string) bool

func (*CronService) SetRuntimeOptions

func (cs *CronService) SetRuntimeOptions(opts RuntimeOptions)

func (*CronService) Start

func (cs *CronService) Start() error

func (*CronService) Status

func (cs *CronService) Status() map[string]interface{}

func (*CronService) Stop

func (cs *CronService) Stop()

func (*CronService) UpdateJob

func (cs *CronService) UpdateJob(jobID string, in UpdateJobInput) (*CronJob, error)

type CronStore

type CronStore struct {
	Version int       `json:"version"`
	Jobs    []CronJob `json:"jobs"`
}

type JobHandler

type JobHandler func(job *CronJob) (string, error)

type RuntimeOptions

type RuntimeOptions struct {
	RunLoopMinSleep              time.Duration
	RunLoopMaxSleep              time.Duration
	RetryBackoffBase             time.Duration
	RetryBackoffMax              time.Duration
	MaxConsecutiveFailureRetries int64
	MaxWorkers                   int
}

func DefaultRuntimeOptions

func DefaultRuntimeOptions() RuntimeOptions

type UpdateJobInput

type UpdateJobInput struct {
	Name           *string
	Enabled        *bool
	Schedule       *CronSchedule
	Message        *string
	Deliver        *bool
	Channel        *string
	To             *string
	DeleteAfterRun *bool
}

Jump to

Keyboard shortcuts

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