cron

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"`
}

type CronPayload

type CronPayload struct {
	Kind    string `json:"kind"`
	Message string `json:"message"`
	Command string `json:"command,omitempty"`
	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,
	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, bool)

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) SetOnJob

func (cs *CronService) SetOnJob(handler JobHandler)

func (*CronService) Start

func (cs *CronService) Start() error

func (*CronService) Status

func (cs *CronService) Status() map[string]any

func (*CronService) Stop

func (cs *CronService) Stop()

func (*CronService) UpdateJob

func (cs *CronService) UpdateJob(job *CronJob) error

type CronStore

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

type JobHandler

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

Jump to

Keyboard shortcuts

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