From b5ec78f82bc7e21b65a7931bed178f7715b9d81b Mon Sep 17 00:00:00 2001 From: Cody Roseborough Date: Wed, 15 Feb 2017 11:34:17 -0800 Subject: [PATCH] Adds streaming schedule type --- pkg/schedule/streaming_schedule.go | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pkg/schedule/streaming_schedule.go diff --git a/pkg/schedule/streaming_schedule.go b/pkg/schedule/streaming_schedule.go new file mode 100644 index 000000000..bd7232dfb --- /dev/null +++ b/pkg/schedule/streaming_schedule.go @@ -0,0 +1,52 @@ +package schedule + +import "time" + +// StreamingSchedule is a schedule that only implements an endless repeating interval +type StreamingSchedule struct { + state ScheduleState +} + +// NewStreamingSchedule returns the SimpleSchedule given the time interval +func NewStreamingSchedule() *StreamingSchedule { + return &StreamingSchedule{} +} + +// GetState returns the schedule state +func (s *StreamingSchedule) GetState() ScheduleState { + return Active +} + +// Validate returns an error if the interval of schedule is less +// or equals zero +func (s *StreamingSchedule) Validate() error { + return nil +} + +// Wait returns the StreamingSchedule state, misses and the last schedule ran +func (s *StreamingSchedule) Wait(last time.Time) Response { + return &StreamingScheduleResponse{} +} + +// StreamingScheduleResponse a response from SimpleSchedule conforming to ScheduleResponse interface +type StreamingScheduleResponse struct{} + +// State returns the state of the Schedule +func (s *StreamingScheduleResponse) State() ScheduleState { + return Active +} + +// Error returns last error +func (s *StreamingScheduleResponse) Error() error { + return nil +} + +// Missed returns any missed intervals +func (s *StreamingScheduleResponse) Missed() uint { + return 0 +} + +// LastTime retruns the last response time +func (s *StreamingScheduleResponse) LastTime() time.Time { + return time.Time{} +}