...

Package timeinterval

import "github.com/prometheus/alertmanager/timeinterval"
Overview
Index

Overview ▾

Index ▾

Constants
type DayOfMonthRange
    func (r *DayOfMonthRange) UnmarshalJSON(in []byte) error
    func (r *DayOfMonthRange) UnmarshalYAML(unmarshal func(interface{}) error) error
type InclusiveRange
    func (ir InclusiveRange) MarshalText() ([]byte, error)
    func (ir InclusiveRange) MarshalYAML() (interface{}, error)
type Location
    func (tz Location) MarshalJSON() (out []byte, err error)
    func (tz Location) MarshalText() ([]byte, error)
    func (tz Location) MarshalYAML() (interface{}, error)
    func (tz *Location) UnmarshalJSON(in []byte) error
    func (tz *Location) UnmarshalYAML(unmarshal func(interface{}) error) error
type MonthRange
    func (r *MonthRange) UnmarshalJSON(in []byte) error
    func (r *MonthRange) UnmarshalYAML(unmarshal func(interface{}) error) error
type TimeInterval
    func (tp TimeInterval) ContainsTime(t time.Time) bool
type TimeRange
    func (tr TimeRange) MarshalJSON() (out []byte, err error)
    func (tr TimeRange) MarshalYAML() (out interface{}, err error)
    func (tr *TimeRange) UnmarshalJSON(in []byte) error
    func (tr *TimeRange) UnmarshalYAML(unmarshal func(interface{}) error) error
type WeekdayRange
    func (r WeekdayRange) MarshalText() ([]byte, error)
    func (r WeekdayRange) MarshalYAML() (interface{}, error)
    func (r *WeekdayRange) UnmarshalJSON(in []byte) error
    func (r *WeekdayRange) UnmarshalYAML(unmarshal func(interface{}) error) error
type YearRange
    func (r *YearRange) UnmarshalJSON(in []byte) error
    func (r *YearRange) UnmarshalYAML(unmarshal func(interface{}) error) error

Package files

timeinterval.go

Constants

TimeLayout specifies the layout to be used in time.Parse() calls for time intervals.

const TimeLayout = "15:04"

type DayOfMonthRange

A DayOfMonthRange is an inclusive range that may have negative Beginning/End values that represent distance from the End of the month Beginning at -1.

type DayOfMonthRange struct {
    InclusiveRange
}

func (*DayOfMonthRange) UnmarshalJSON

func (r *DayOfMonthRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for DayOfMonthRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*DayOfMonthRange) UnmarshalYAML

func (r *DayOfMonthRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for DayOfMonthRange.

type InclusiveRange

InclusiveRange is used to hold the Beginning and End values of many time interval components.

type InclusiveRange struct {
    Begin int
    End   int
}

func (InclusiveRange) MarshalText

func (ir InclusiveRange) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for InclusiveRange. It converts the struct into a colon-separated string, or a single element if appropriate. e.g. "monday:friday" or "monday"

func (InclusiveRange) MarshalYAML

func (ir InclusiveRange) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for InclusiveRange.

type Location

A Location is a container for a time.Location, used for custom unmarshalling/validation logic.

type Location struct {
    *time.Location
}

func (Location) MarshalJSON

func (tz Location) MarshalJSON() (out []byte, err error)

MarshalJSON implements the json.Marshaler interface for Location.

func (Location) MarshalText

func (tz Location) MarshalText() ([]byte, error)

MarshalText implements the econding.TextMarshaler interface for Location. It marshals a Location back into a string that represents a time.Location.

func (Location) MarshalYAML

func (tz Location) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for Location.

func (*Location) UnmarshalJSON

func (tz *Location) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Location. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*Location) UnmarshalYAML

func (tz *Location) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for Location.

type MonthRange

A MonthRange is an inclusive range between [1, 12] where 1 = January.

type MonthRange struct {
    InclusiveRange
}

func (*MonthRange) UnmarshalJSON

func (r *MonthRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for MonthRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*MonthRange) UnmarshalYAML

func (r *MonthRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for MonthRange.

type TimeInterval

TimeInterval describes intervals of time. ContainsTime will tell you if a golang time is contained within the interval.

type TimeInterval struct {
    Times       []TimeRange       `yaml:"times,omitempty" json:"times,omitempty"`
    Weekdays    []WeekdayRange    `yaml:"weekdays,flow,omitempty" json:"weekdays,omitempty"`
    DaysOfMonth []DayOfMonthRange `yaml:"days_of_month,flow,omitempty" json:"days_of_month,omitempty"`
    Months      []MonthRange      `yaml:"months,flow,omitempty" json:"months,omitempty"`
    Years       []YearRange       `yaml:"years,flow,omitempty" json:"years,omitempty"`
    Location    *Location         `yaml:"location,flow,omitempty" json:"location,omitempty"`
}

func (TimeInterval) ContainsTime

func (tp TimeInterval) ContainsTime(t time.Time) bool

ContainsTime returns true if the TimeInterval contains the given time, otherwise returns false.

type TimeRange

TimeRange represents a range of minutes within a 1440 minute day, exclusive of the End minute. A day consists of 1440 minutes. For example, 4:00PM to End of the day would Begin at 1020 and End at 1440.

type TimeRange struct {
    StartMinute int
    EndMinute   int
}

func (TimeRange) MarshalJSON

func (tr TimeRange) MarshalJSON() (out []byte, err error)

MarshalJSON implements the json.Marshaler interface for TimeRange.

func (TimeRange) MarshalYAML

func (tr TimeRange) MarshalYAML() (out interface{}, err error)

MarshalYAML implements the yaml.Marshaler interface for TimeRange.

func (*TimeRange) UnmarshalJSON

func (tr *TimeRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Timerange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*TimeRange) UnmarshalYAML

func (tr *TimeRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for TimeRanges.

type WeekdayRange

A WeekdayRange is an inclusive range between [0, 6] where 0 = Sunday.

type WeekdayRange struct {
    InclusiveRange
}

func (WeekdayRange) MarshalText

func (r WeekdayRange) MarshalText() ([]byte, error)

MarshalText implements the econding.TextMarshaler interface for WeekdayRange. It converts the range into a colon-separated string, or a single weekday if possible. e.g. "monday:friday" or "saturday".

func (WeekdayRange) MarshalYAML

func (r WeekdayRange) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for WeekdayRange.

func (*WeekdayRange) UnmarshalJSON

func (r *WeekdayRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for WeekdayRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*WeekdayRange) UnmarshalYAML

func (r *WeekdayRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for WeekdayRange.

type YearRange

A YearRange is a positive inclusive range.

type YearRange struct {
    InclusiveRange
}

func (*YearRange) UnmarshalJSON

func (r *YearRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for YearRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*YearRange) UnmarshalYAML

func (r *YearRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for YearRange.