Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Adds streaming schedule type
Browse files Browse the repository at this point in the history
  • Loading branch information
croseborough committed Mar 3, 2017
1 parent d4b65a5 commit b5ec78f
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions pkg/schedule/streaming_schedule.go
Original file line number Diff line number Diff line change
@@ -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{}
}

0 comments on commit b5ec78f

Please sign in to comment.