Skip to content

Instantly share code, notes, and snippets.

@gnsx
Created March 16, 2019 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnsx/50a30c81b2fbf2222537c6da806effe8 to your computer and use it in GitHub Desktop.
Save gnsx/50a30c81b2fbf2222537c6da806effe8 to your computer and use it in GitHub Desktop.
//Sort implementation for custom types
// Encapsulates the statistical data that CloudWatch computes from metric data.
type Datapoint struct {
_ struct{} `type:"structure"`
// The average of the metric values that correspond to the data point.
Average *float64 `type:"double"`
// The percentile statistic for the data point.
ExtendedStatistics map[string]*float64 `type:"map"`
// The maximum metric value for the data point.
Maximum *float64 `type:"double"`
// The minimum metric value for the data point.
Minimum *float64 `type:"double"`
// The number of metric values that contributed to the aggregate value of this
// data point.
SampleCount *float64 `type:"double"`
// The sum of the metric values for the data point.
Sum *float64 `type:"double"`
// The time stamp used for the data point.
Timestamp *time.Time `type:"timestamp"`
// The standard unit for the data point.
Unit *string `type:"string" enum:"StandardUnit"`
}
type dataPoint []*cloudwatch.Datapoint
func (a dataPoint) Len() int { return len(a) }
func (a dataPoint) Less(i, j int) bool { return a[i].Timestamp.Before(*a[j].Timestamp) }
func (a dataPoint) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
sort.Sort(dataPoint(resultConsumed.Datapoints))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment