Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLoggingRoundTripper ¶
func AddLoggingRoundTripper(inner http.RoundTripper) http.RoundTripper
AddLoggingRoundTripper adds logging for long round trips to http.RoundTripper. This is used to provide visibility into slow backend API calls.
func IDsToJSON ¶
IDsToJSON embeds a list of string IDs in a data structure that serializes to JSON like [{"id":"first"},{"id":"second"}].
func StringSliceContains ¶
StringSliceContains checks whether a slice contains a string.
func UnpackError ¶
UnpackError is usually a no-op, but for some Gophercloud errors, it removes the outer layer that obscures the better error message hidden within.
Types ¶
type Float64OrUnknown ¶
type Float64OrUnknown float64
Float64OrUnknown extracts a value of type float64 or unknown from a json result is an float64
func (*Float64OrUnknown) UnmarshalJSON ¶
func (f *Float64OrUnknown) UnmarshalJSON(buffer []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
type MarshalableTimeDuration ¶
func (MarshalableTimeDuration) Into ¶
func (d MarshalableTimeDuration) Into() time.Duration
Into is a short-hand for casting into time.Duration.
func (*MarshalableTimeDuration) UnmarshalYAML ¶
func (d *MarshalableTimeDuration) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.
type TimeSeries ¶
TimeSeries is a minimalistic implementation of a time series (a representation of a metric that assumes different values over time), tailored towards the exact needs of the project_az_resources.historical_usage attribute.
func EmptyTimeSeries ¶
func EmptyTimeSeries[T cmp.Ordered]() TimeSeries[T]
EmptyTimeSeries constructs a new empty TimeSeries.
func ParseTimeSeries ¶
func ParseTimeSeries[T cmp.Ordered](input string) (TimeSeries[T], error)
ParseTimeSeries parses the JSON representation of a time series, or returns an empty time series if the input is the empty string.
NOTE: We do not implement UnmarshalJSON since this function offers a more convenient interface for our actual usecases.
func (*TimeSeries[T]) AddMeasurement ¶
func (s *TimeSeries[T]) AddMeasurement(now time.Time, value T) error
AddMeasurement adds a new point to this time series, unless the previous point in time has the same value. An error is returned if the time series already contains measurements from a time after `now`.
func (TimeSeries[T]) MaxOr ¶
func (s TimeSeries[T]) MaxOr(fallback T) T
MaxOr returns the maximum of this time series, or the provided fallback value if it is empty.
func (TimeSeries[T]) MinOr ¶
func (s TimeSeries[T]) MinOr(fallback T) T
MinOr returns the minimum of this time series, or the provided fallback value if it is empty.
func (*TimeSeries[T]) PruneOldValues ¶
func (s *TimeSeries[T]) PruneOldValues(now time.Time, retentionPeriod time.Duration)
PruneOldValues removes all measurements that fall before `now.Add(-retentionPeriod)`.
func (TimeSeries[T]) Serialize ¶
func (s TimeSeries[T]) Serialize() (string, error)
Serialize returns the JSON representation of this timeseries.
NOTE: We do not implement MarshalJSON since this function offers a more convenient interface for our actual usecases.
type YamlRawMessage ¶
type YamlRawMessage []byte
YamlRawMessage is like json.RawMessage: During yaml.Unmarshal(), it will just collect the provided YAML representation instead of parsing it into a specific datatype. It can be used to defer parsing when the concrete target type is not yet known when the YAML input is initially unmarshalled.
func (*YamlRawMessage) UnmarshalYAML ¶
func (m *YamlRawMessage) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.