Help us shape the future of Go! Take the 2026 Go Developer Survey

cron

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 10 Imported by: 1

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 added in v0.3.0

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 added in v0.1.1

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 added in v0.1.1

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