Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("job not found")
)
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// ID is the cron-assigned ID of this entry, which may be used to look up a
// snapshot or remove it.
ID EntryID
Type EntryType
Status EntryStatus
// Schedule is the string representation of job schedule
Schedule schedule.Schedule
// Next time the job will run, or the zero time if Cron has not been
// started or this entry's schedule is unsatisfiable
Next int64
// Prev is the last time this job was run, or the zero time if never.
Prev int64
// Payload is a raw representation of job context
Payload []byte
}
Entry contains general information about the job
type EntryStatus ¶
type EntryStatus int
const ( Scheduled EntryStatus = iota Active Succeeded Failed )
type JobSetter ¶
type JobSetter func(*Entry)
EntrySetter changes values of Entry fields
func SetPayload ¶
func SetSchedule ¶
func SetStatus ¶
func SetStatus(s EntryStatus) JobSetter
type Store ¶
type Store interface {
// Register appends the Entry to the set of scheduled jobs
Register(Entry) error
// Entry returns Entry by EntryID or empty value
// if such job doesn't registered
Entry(EntryID, schedule.Parser) (Entry, error)
// Update modifies the job by applying EntrySetters to the instance
Update(EntryID, schedule.Parser, ...JobSetter) error
// Remove removes the Entry from the set of scheduled jobs
Remove(EntryID) error
// Snapshot returns a snapshot of the set of scheduled jobs
Snapshot(schedule.Parser) ([]Entry, error)
// Next returns EntryID and start time of the soonest job
Next() (EntryID, time.Time, error)
// Ready returns slice of entries which are
// ready to start at the particular time
Ready(time.Time, schedule.Parser) ([]Entry, error)
}
Store encapsulates a logic of interaction with scheduled jobs. Cron assumes exclusive store possession, so you shouldn't use it directly while cron is running to prevent unexpected behaviour.
Click to show internal directories.
Click to hide internal directories.