Documentation ¶
Index ¶
- Variables
- type MaintenanceTime
- func (m *MaintenanceTime) Add(hour, minute, second int) *MaintenanceTime
- func (m *MaintenanceTime) Compare(other *MaintenanceTime) int
- func (m *MaintenanceTime) Formatted() string
- func (m *MaintenanceTime) Hour() int
- func (m *MaintenanceTime) Minute() int
- func (m *MaintenanceTime) Second() int
- func (m *MaintenanceTime) String() string
- type MaintenanceTimeWindow
- func (m *MaintenanceTimeWindow) Begin() *MaintenanceTime
- func (m *MaintenanceTimeWindow) Contains(tTime time.Time) bool
- func (m *MaintenanceTimeWindow) Duration() time.Duration
- func (m *MaintenanceTimeWindow) End() *MaintenanceTime
- func (m *MaintenanceTimeWindow) Equal(o *MaintenanceTimeWindow) bool
- func (m *MaintenanceTimeWindow) RandomDurationUntilNext(from time.Time, shiftBeginToFromIfContained bool) time.Duration
- func (m *MaintenanceTimeWindow) String() string
- func (m *MaintenanceTimeWindow) WithBegin(begin *MaintenanceTime) *MaintenanceTimeWindow
- func (m *MaintenanceTimeWindow) WithEnd(end *MaintenanceTime) *MaintenanceTimeWindow
Constants ¶
This section is empty.
Variables ¶
var AlwaysTimeWindow = NewMaintenanceTimeWindow(NewMaintenanceTime(0, 0, 0), NewMaintenanceTime(23, 59, 59))
AlwaysTimeWindow is a MaintenanceTimeWindow that contains all durations.
var RandomFunc = rand.Int63nRange
RandomFunc is a function that computes a random number.
Functions ¶
This section is empty.
Types ¶
type MaintenanceTime ¶
type MaintenanceTime struct {
// contains filtered or unexported fields
}
MaintenanceTime is a structure holding a maintenance time.
func NewMaintenanceTime ¶
func NewMaintenanceTime(hour, minute, second int) *MaintenanceTime
NewMaintenanceTime returns a maintenance time structure based on the given hour, minute, and second.
func ParseMaintenanceTime ¶
func ParseMaintenanceTime(value string) (*MaintenanceTime, error)
ParseMaintenanceTime parses the given value and returns it as MaintenanceTime object. In case the parsing fails, an error is returned. The time object is converted to UTC zone.
func (*MaintenanceTime) Add ¶
func (m *MaintenanceTime) Add(hour, minute, second int) *MaintenanceTime
Add adds hour, minute and second to <m> and returns a new maintenance time.
func (*MaintenanceTime) Compare ¶
func (m *MaintenanceTime) Compare(other *MaintenanceTime) int
Compare compares the two times <m> and <other>. It returns * i < 0 if <m> is before other * i = 0 if <m> is equal other * i > 0 if <m> is after other
func (*MaintenanceTime) Formatted ¶
func (m *MaintenanceTime) Formatted() string
Formatted formats the maintenance time object to the maintenance time format.
func (*MaintenanceTime) Hour ¶
func (m *MaintenanceTime) Hour() int
Hour returns the hour of the maintenance time.
func (*MaintenanceTime) Minute ¶
func (m *MaintenanceTime) Minute() int
Minute returns the minute of the maintenance time.
func (*MaintenanceTime) Second ¶
func (m *MaintenanceTime) Second() int
Second returns the second of the maintenance time.
func (*MaintenanceTime) String ¶
func (m *MaintenanceTime) String() string
String returns the string representation of the maintenance time.
type MaintenanceTimeWindow ¶
type MaintenanceTimeWindow struct {
// contains filtered or unexported fields
}
MaintenanceTimeWindow contains the beginning and the end of a time window in which maintenance operations can be performed.
func NewMaintenanceTimeWindow ¶
func NewMaintenanceTimeWindow(begin, end *MaintenanceTime) *MaintenanceTimeWindow
NewMaintenanceTimeWindow takes a begin and an end of a time window and returns a pointer to a MaintenanceTimeWindow structure.
func ParseMaintenanceTimeWindow ¶
func ParseMaintenanceTimeWindow(begin, end string) (*MaintenanceTimeWindow, error)
ParseMaintenanceTimeWindow takes a begin and an end of a time window in the maintenance format and returns a pointer to a MaintenanceTimeWindow structure.
func RandomMaintenanceTimeWindow ¶
func RandomMaintenanceTimeWindow() *MaintenanceTimeWindow
RandomMaintenanceTimeWindow computes a random time window and returns both in the format HHMMSS+ZONE.
func (*MaintenanceTimeWindow) Begin ¶
func (m *MaintenanceTimeWindow) Begin() *MaintenanceTime
Begin returns the begin of the time window.
func (*MaintenanceTimeWindow) Contains ¶
func (m *MaintenanceTimeWindow) Contains(tTime time.Time) bool
Contains returns true in case the given time is within the time window.
func (*MaintenanceTimeWindow) Duration ¶
func (m *MaintenanceTimeWindow) Duration() time.Duration
Duration returns the duration of the maintenance time window.
func (*MaintenanceTimeWindow) End ¶
func (m *MaintenanceTimeWindow) End() *MaintenanceTime
End returns the end of the time window.
func (*MaintenanceTimeWindow) Equal ¶
func (m *MaintenanceTimeWindow) Equal(o *MaintenanceTimeWindow) bool
Equal returns true if the time windows are the same.
func (*MaintenanceTimeWindow) RandomDurationUntilNext ¶
func (m *MaintenanceTimeWindow) RandomDurationUntilNext(from time.Time, shiftBeginToFromIfContained bool) time.Duration
RandomDurationUntilNext computes the duration until a random time within the time window for the next maintenance execution. The <from> parameter is the time from which the calculation for the next maintenance time window shall be performed (typically: time.Now()). The <shiftBeginToFromIfContained> parameter controls whether the beginning of the maintenance time window should be changed to <from> if <from> is already inside the maintenance time window (otherwise, it has no effect). As a consequence, this will return a random duration from <from> until the end of the maintenance time window which is shorter than 24h.
func (*MaintenanceTimeWindow) String ¶
func (m *MaintenanceTimeWindow) String() string
String returns the string representation of the time window.
func (*MaintenanceTimeWindow) WithBegin ¶
func (m *MaintenanceTimeWindow) WithBegin(begin *MaintenanceTime) *MaintenanceTimeWindow
WithBegin returns a new maintenance time window with the given <begin> (ending will be kept).
func (*MaintenanceTimeWindow) WithEnd ¶
func (m *MaintenanceTimeWindow) WithEnd(end *MaintenanceTime) *MaintenanceTimeWindow
WithEnd returns a new maintenance time window with the given <end> (beginning will be kept).