schedule

package
v0.0.0-...-430e8a6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func NewDayFrequency(atMinutes []int, atHours []int) (Frequency, error)

NewDayFrequency creates a new struct that represents a day frequency

func NewHourFrequency

func NewHourFrequency(atMinutes []int) (Frequency, error)

NewHourFrequency creates a new struct that represents an hour frequency

func NewMonthFrequency

func NewMonthFrequency(atMinutes []int, atHours []int, onDays []int) (Frequency, error)

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

func NewWeekFrequency(atMinutes []int, atHours []int, onDays []time.Weekday) (Frequency, error)

NewWeekFrequency creates a new struct that represents a week frequency

func (*Frequency) AtHours

func (f *Frequency) AtHours() []int

AtHours returns the frequency's atHours value

func (*Frequency) AtMinutes

func (f *Frequency) AtMinutes() []int

AtMinutes returns the frequency's atMinutes value

func (*Frequency) Interval

func (f *Frequency) Interval() int

Interval returns the frequency's interval value

func (*Frequency) Offset

func (f *Frequency) Offset() int

Offset returns the frequency's offset value

func (*Frequency) OnDaysOfMonth

func (f *Frequency) OnDaysOfMonth() []int

OnDaysOfMonth returns the frequency's onDaysOfMonth value

func (*Frequency) OnDaysOfWeek

func (f *Frequency) OnDaysOfWeek() []time.Weekday

OnDaysOfWeek returns the frequency's onDaysOfWeek value

func (*Frequency) SetInterval

func (f *Frequency) SetInterval(interval int) error

SetInterval sets an interval between each time period

func (*Frequency) SetOffset

func (f *Frequency) SetOffset(offset int) error

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

func (*RecurringTask) Name

func (rt *RecurringTask) Name() string

Name returns the task namee

type Schedule

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

Schedule represents a collection of tasks that recur at some frequency

func New

func New(f Frequency, createdBy user.ID) *Schedule

New instantiates a new schedule entity

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

func (s *Schedule) Check(time time.Time) error

Check sets the lastChecked time

func (*Schedule) CreatedBy

func (s *Schedule) CreatedBy() user.ID

CreatedBy returns the user ID of the user that created the schedule

func (*Schedule) Frequency

func (s *Schedule) Frequency() Frequency

Frequency returns the frequency of this schedule

func (*Schedule) IsValid

func (s *Schedule) IsValid() bool

IsValid returns whether a schedule is valid and can be operated upon

func (*Schedule) LastChecked

func (s *Schedule) LastChecked() time.Time

LastChecked returns the last time this schedule was checked for recurrences

func (*Schedule) NextTime

func (s *Schedule) NextTime(after time.Time) (time.Time, error)

NextTime gets the next scheduled time after the given time

func (*Schedule) Pause

func (s *Schedule) Pause()

Pause pauses a schedule

func (*Schedule) Paused

func (s *Schedule) Paused() bool

Paused returns whether schedule is currently paused

func (*Schedule) Remove

func (s *Schedule) Remove() error

Remove removes a schedule

func (*Schedule) RemoveTask

func (s *Schedule) RemoveTask(rt RecurringTask) error

RemoveTask removes an existing recurring task from the schedule

func (*Schedule) RemovedTime

func (s *Schedule) RemovedTime() time.Time

RemovedTime returns removed time

func (*Schedule) Tasks

func (s *Schedule) Tasks() []RecurringTask

Tasks returns the slice of recurring tasks associated with a schedule

func (*Schedule) Times

func (s *Schedule) Times(start time.Time, end time.Time) ([]time.Time, error)

Times gets a list of scheduled times between the start and end times

func (*Schedule) Unpause

func (s *Schedule) Unpause()

Unpause unpauses 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

Jump to

Keyboard shortcuts

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