Documentation
¶
Index ¶
- type Frequency
- func NewDayFrequency(atMinutes []int, atHours []int) (Frequency, error)
- func NewHourFrequency(atMinutes []int) (Frequency, error)
- func NewMonthFrequency(atMinutes []int, atHours []int, onDays []int) (Frequency, error)
- func NewRawFrequency(offset int, interval int, timePeriod TimePeriod, atMinutes []int, ...) (Frequency, error)
- func NewWeekFrequency(atMinutes []int, atHours []int, onDays []time.Weekday) (Frequency, error)
- func (f *Frequency) AtHours() []int
- func (f *Frequency) AtMinutes() []int
- func (f *Frequency) Interval() int
- func (f *Frequency) Offset() int
- func (f *Frequency) OnDaysOfMonth() []int
- func (f *Frequency) OnDaysOfWeek() []time.Weekday
- func (f *Frequency) SetInterval(interval int) error
- func (f *Frequency) SetOffset(offset int) error
- func (f *Frequency) TimePeriod() TimePeriod
- type RecurringTask
- type Schedule
- func (s *Schedule) AddTask(rt RecurringTask) error
- func (s *Schedule) Check(time time.Time) error
- func (s *Schedule) CreatedBy() user.ID
- func (s *Schedule) Frequency() Frequency
- func (s *Schedule) IsValid() bool
- func (s *Schedule) LastChecked() time.Time
- func (s *Schedule) NextTime(after time.Time) (time.Time, error)
- func (s *Schedule) Pause()
- func (s *Schedule) Paused() bool
- func (s *Schedule) Remove() error
- func (s *Schedule) RemoveTask(rt RecurringTask) error
- func (s *Schedule) RemovedTime() time.Time
- func (s *Schedule) Tasks() []RecurringTask
- func (s *Schedule) Times(start time.Time, end time.Time) ([]time.Time, error)
- func (s *Schedule) Unpause()
- type TimePeriod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frequency ¶
type Frequency struct {
// contains filtered or unexported fields
}
Frequency defines how often an event occurs
func NewDayFrequency ¶
NewDayFrequency creates a new struct that represents a day frequency
func NewHourFrequency ¶
NewHourFrequency creates a new struct that represents an hour frequency
func NewMonthFrequency ¶
NewMonthFrequency creates a new struct that represents a month frequency
func NewRawFrequency ¶
func NewRawFrequency(offset int, interval int, timePeriod TimePeriod, atMinutes []int, atHours []int, onDaysOfWeek []time.Weekday, onDaysOfMonth []int) (Frequency, error)
NewRawFrequency creates a new frequency struct from raw data
func NewWeekFrequency ¶
NewWeekFrequency creates a new struct that represents a week frequency
func (*Frequency) OnDaysOfMonth ¶
OnDaysOfMonth returns the frequency's onDaysOfMonth value
func (*Frequency) OnDaysOfWeek ¶
OnDaysOfWeek returns the frequency's onDaysOfWeek value
func (*Frequency) SetInterval ¶
SetInterval sets an interval between each time period
func (*Frequency) SetOffset ¶
SetOffset sets an offset from the base of each starting time Base starting times for each time period:
- Hourly: Midnight
- Daily: 1st day of the year
- Weekly: 1st week of the year
- Monthly: January
func (*Frequency) TimePeriod ¶
func (f *Frequency) TimePeriod() TimePeriod
TimePeriod returns the frequency's timePeriod value
type RecurringTask ¶
type RecurringTask struct {
// contains filtered or unexported fields
}
RecurringTask represents a task that recurs on a schedule
func NewRecurringTask ¶
func NewRecurringTask(name string, description string) RecurringTask
NewRecurringTask instantiates a new recurring task entity
func (*RecurringTask) Description ¶
func (rt *RecurringTask) Description() string
Description returns the task description
func (*RecurringTask) Equal ¶
func (rt *RecurringTask) Equal(rtc RecurringTask) bool
Equal returns whether 2 recurring tasks are equal
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule represents a collection of tasks that recur at some frequency
func NewRaw ¶
func NewRaw(frequency Frequency, paused bool, lastChecked time.Time, tasks []RecurringTask, removedTime time.Time, createdBy user.ID) *Schedule
NewRaw creates a new schedule entity from raw data
func (*Schedule) AddTask ¶
func (s *Schedule) AddTask(rt RecurringTask) error
AddTask adds a new recurring task if it doesn't already exist
func (*Schedule) LastChecked ¶
LastChecked returns the last time this schedule was checked for recurrences
func (*Schedule) RemoveTask ¶
func (s *Schedule) RemoveTask(rt RecurringTask) error
RemoveTask removes an existing recurring task from the schedule
func (*Schedule) RemovedTime ¶
RemovedTime returns removed time
func (*Schedule) Tasks ¶
func (s *Schedule) Tasks() []RecurringTask
Tasks returns the slice of recurring tasks associated with a schedule
type TimePeriod ¶
type TimePeriod uint8
TimePeriod identifies which time period a schedule interval applies
const ( TimePeriodNone TimePeriod = iota TimePeriodHour TimePeriodDay TimePeriodWeek TimePeriodMonth )
TimePeriod constants define which time period a schedule interval applies
func (TimePeriod) String ¶
func (tp TimePeriod) String() string