This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4b65a5
commit b5ec78f
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{} | ||
} |