Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response interface { // Contains any errors captured during a schedule.Wait() Error() error // Returns the schedule state State() ScheduleState // Returns any intervals that were missed since the call to Wait() Missed() uint // The time the interval fired LastTime() time.Time }
type Schedule ¶
type Schedule interface { // Returns the current state of the schedule GetState() ScheduleState // Returns where a schedule is still valid for this point in time. Validate() error // Blocks until time to fire and returns a schedule.Response Wait(time.Time) Response }
type ScheduleState ¶
type ScheduleState int
const ( // set by the scheduler once a schedule has been validated and is in use in a task Active ScheduleState = iota // Schedule is ended Ended // Schedule is halted with an error Error )
type SimpleSchedule ¶
A schedule that only implements an endless repeating interval
func NewSimpleSchedule ¶
func NewSimpleSchedule(i time.Duration) *SimpleSchedule
func (*SimpleSchedule) GetState ¶
func (s *SimpleSchedule) GetState() ScheduleState
func (*SimpleSchedule) Validate ¶
func (s *SimpleSchedule) Validate() error
func (*SimpleSchedule) Wait ¶
func (s *SimpleSchedule) Wait(last time.Time) Response
Waits until net interval and returns true. Returning false signals a Schedule is no longer valid and should be halted. A SimpleSchedule has no end and as long as start is not in the future we will always in practice return true.
type SimpleScheduleResponse ¶
type SimpleScheduleResponse struct {
// contains filtered or unexported fields
}
A response from SimpleSchedule conforming to ScheduleResponse interface
func (*SimpleScheduleResponse) Error ¶
func (s *SimpleScheduleResponse) Error() error
Returns last error
func (*SimpleScheduleResponse) LastTime ¶
func (s *SimpleScheduleResponse) LastTime() time.Time
func (*SimpleScheduleResponse) Missed ¶
func (s *SimpleScheduleResponse) Missed() uint
Returns any missed intervals
func (*SimpleScheduleResponse) State ¶
func (s *SimpleScheduleResponse) State() ScheduleState
Returns the state of the Schedule
type WindowedSchedule ¶
type WindowedSchedule struct { Interval time.Duration StartTime *time.Time StopTime *time.Time // contains filtered or unexported fields }
A schedule that waits on an interval within a specific time window
func NewWindowedSchedule ¶
func (*WindowedSchedule) GetState ¶
func (w *WindowedSchedule) GetState() ScheduleState
func (*WindowedSchedule) Validate ¶
func (w *WindowedSchedule) Validate() error
type WindowedScheduleResponse ¶
type WindowedScheduleResponse struct {
// contains filtered or unexported fields
}
A response from SimpleSchedule conforming to ScheduleResponse interface
func (*WindowedScheduleResponse) Error ¶
func (w *WindowedScheduleResponse) Error() error
Returns last error
func (*WindowedScheduleResponse) LastTime ¶
func (w *WindowedScheduleResponse) LastTime() time.Time
func (*WindowedScheduleResponse) Missed ¶
func (w *WindowedScheduleResponse) Missed() uint
Returns any missed intervals
func (*WindowedScheduleResponse) State ¶
func (w *WindowedScheduleResponse) State() ScheduleState
Returns the state of the Schedule