Version: v1.49.0 Latest Latest

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 4 Imported by: 0



Package schedule defines the interface for scheduling of slackscot actions



View Source
const (
	Weeks   = IntervalUnit("weeks")
	Hours   = IntervalUnit("hours")
	Days    = IntervalUnit("days")
	Minutes = IntervalUnit("minutes")
	Seconds = IntervalUnit("seconds")

IntervalUnit values


This section is empty.


func NewJob

func NewJob(s *gocron.Scheduler, def Definition) (j *gocron.Job, err error)

NewJob sets up the gocron.Job with the schedule and leaves the task undefined for the caller to set up


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

AtTime sets the time of the day to run. Only makes sense for schedules with an interval larger than 1 day

func (*ScheduleDefinitionBuilder) Build

Build returns the schedule Definition

func (*ScheduleDefinitionBuilder) Every

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

WithUnit sets the schedule interval unit. Can't be set along with weekday (via Every)

Source Files

Jump to

Keyboard shortcuts

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