Documentation ¶
Overview ¶
Package schedule defines the interface for scheduling of slackscot actions
Index ¶
- Constants
- func NewJob(s *gocron.Scheduler, def Definition) (j *gocron.Job, err error)
- type DayOfWeek
- type Definition
- type IntervalUnit
- type ScheduleDefinitionBuilder
- func (sdb *ScheduleDefinitionBuilder) AtTime(atTime string) *ScheduleDefinitionBuilder
- func (sdb *ScheduleDefinitionBuilder) Build() Definition
- func (sdb *ScheduleDefinitionBuilder) Every(weekday string) *ScheduleDefinitionBuilder
- func (sdb *ScheduleDefinitionBuilder) WithInterval(interval uint64, unit IntervalUnit) *ScheduleDefinitionBuilder
- func (sdb *ScheduleDefinitionBuilder) WithUnit(unit IntervalUnit) *ScheduleDefinitionBuilder
Constants ¶
const ( Weeks = IntervalUnit("weeks") Hours = IntervalUnit("hours") Days = IntervalUnit("days") Minutes = IntervalUnit("minutes") Seconds = IntervalUnit("seconds") )
IntervalUnit values
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DayOfWeek ¶
type DayOfWeek string
DayOfWeek is the type definition for a string value of days of the week (based on time.Day.String())
type Definition ¶
type Definition struct { // Internal value (every 1 minute would be expressed with an interval of 1). Must be set explicitly or implicitly (a weekday value implicitly sets the interval to 1) Interval uint64 // Must be set explicitly or implicitly ("weeks" is implicitly set when "Weekday" is set). Valid time units are: "weeks", "hours", "days", "minutes", "seconds" Unit IntervalUnit // Optional day of the week. If set, unit and interval are ignored and implicitly considered to be "every 1 week" Weekday string // Optional "at time" value (i.e. "10:30") AtTime string }
Definition holds the data defining a schedule definition
func (Definition) String ¶
func (d Definition) String() string
Returns a human-friendly string for the schedule definition
type IntervalUnit ¶
type IntervalUnit string
IntervalUnit is the type definition for a string value representing an interval unit
type ScheduleDefinitionBuilder ¶
type ScheduleDefinitionBuilder struct {
// contains filtered or unexported fields
}
ScheduleDefinitionBuilder holds a schedule Definition to build
func New ¶
func New() (sdb *ScheduleDefinitionBuilder)
New creates a new ScheduleDefinitionBuilder to set up a schedule Definition
func (*ScheduleDefinitionBuilder) AtTime ¶
func (sdb *ScheduleDefinitionBuilder) AtTime(atTime string) *ScheduleDefinitionBuilder
AtTime sets the time of the day to run. Only makes sense for schedules with an interval larger than 1 day
func (*ScheduleDefinitionBuilder) Build ¶
func (sdb *ScheduleDefinitionBuilder) Build() Definition
Build returns the schedule Definition
func (*ScheduleDefinitionBuilder) Every ¶
func (sdb *ScheduleDefinitionBuilder) Every(weekday string) *ScheduleDefinitionBuilder
Every sets the day of the week to run on. Use time.<Day>.String() values. Can't be set along with WithUnit
func (*ScheduleDefinitionBuilder) WithInterval ¶
func (sdb *ScheduleDefinitionBuilder) WithInterval(interval uint64, unit IntervalUnit) *ScheduleDefinitionBuilder
WithInterval sets the schedule interval and unit (every week would be interval 1 and unit Weeks)
func (*ScheduleDefinitionBuilder) WithUnit ¶
func (sdb *ScheduleDefinitionBuilder) WithUnit(unit IntervalUnit) *ScheduleDefinitionBuilder
WithUnit sets the schedule interval unit. Can't be set along with weekday (via Every)