Documentation
¶
Overview ¶
Package window provides window configuration retrieval and formatting capability.
Index ¶
- type ConfigReader
- type Format
- type Map
- func (m Map) Add(windows ...Window)
- func (m Map) AggregateSchedules(request string) []Schedule
- func (m Map) Find(l string) []Window
- func (m Map) FindWindow(window, label string) Window
- func (m Map) Keys() []string
- func (m Map) MarshalJSON() ([]byte, error)
- func (m Map) UniqueWindows() []Window
- func (m Map) UnmarshalJSON(b []byte) error
- type Reader
- type Schedule
- type Window
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigReader ¶
type ConfigReader interface { PathExists(string) (bool, error) AbsPath(string) (string, error) JSONFiles(string) ([]os.FileInfo, error) JSONContent(string) ([]byte, error) }
ConfigReader defines filesystem interactions for Window configurations.
type Map ¶
Map correlates windows to their defined labels.
func Windows ¶
func Windows(dir string, cr ConfigReader) (Map, error)
Windows gets all defined windows within given directory.
func (Map) AggregateSchedules ¶
AggregateSchedules combines the schedules of labels that match a given string with those that overlap.
This has the potential to return two or more schedules that that do not overlap. Schedule state happens within Aukera's schedule package.
func (Map) FindWindow ¶
FindWindow returns a Window with a given name from a slice of windows organized by label.
func (Map) MarshalJSON ¶
MarshalJSON marshals Window Map to configuration JSON.
func (Map) UniqueWindows ¶
UniqueWindows returns all distinct windows stored in the Map.
func (Map) UnmarshalJSON ¶
UnmarshalJSON is a custom window Map unmarshaler.
type Reader ¶
type Reader struct{}
Reader is the implementation of ConfigReader for the window package.
func (Reader) AbsPath ¶
AbsPath converts a given path to an absolute path and evaluates its existence.
func (Reader) JSONContent ¶
JSONContent returns the contents of JSON files.
type Schedule ¶
Schedule defines struct for schedule information.
func (*Schedule) MarshalJSON ¶
MarshalJSON is a custom marshaler for Schedule to ensure the Duration value is marshalled as a human-readable string.
func (*Schedule) UnmarshalJSON ¶
UnmarshalJSON is a custom unmarshaller for Schedule struct. Used with client package to retrieve window schedule.
type Window ¶
type Window struct {
Name, CronString string
Format Format
Cron cron.Schedule
Duration time.Duration
Starts, Expires time.Time
Labels []string
Schedule Schedule
}
Window for holding raw window JSON data.
func (*Window) Expired ¶
Expired determines window validity comparing Expiration time to time.Now().
func (*Window) LastActivation ¶
LastActivation determines the last activation time of cron.Schedule. Cron itself is unaware of the duration of the window and states the window is closed if the defined cron is in the past. LastActivation travels back in time equal to the duration between now and the "Next" activation to find the starting timestamp of the last window.
func (Window) MarshalJSON ¶
MarshalJSON is a custom marshaler for Window to ensure JSON output matches the fields within its configuration file.
func (*Window) NextActivation ¶
NextActivation determines the next activation time of cron.Schedule. This function crawls back in time search last and current time values for match, solving case where each second within the cron string itself is a valid "Next" value.
func (*Window) UnmarshalJSON ¶
UnmarshalJSON is a custom Window unmarshaler.