in aggregators/config.go [232:269]
func validateCfg(cfg config) error {
if cfg.DataDir == "" {
return errors.New("data directory is required")
}
if cfg.Processor == nil {
return errors.New("processor is required")
}
if cfg.Partitions == 0 {
return errors.New("partitions must be greater than zero")
}
if len(cfg.AggregationIntervals) == 0 {
return errors.New("at least one aggregation interval is required")
}
if !sort.SliceIsSorted(cfg.AggregationIntervals, func(i, j int) bool {
return cfg.AggregationIntervals[i] < cfg.AggregationIntervals[j]
}) {
return errors.New("aggregation intervals must be in ascending order")
}
lowest := cfg.AggregationIntervals[0]
highest := cfg.AggregationIntervals[len(cfg.AggregationIntervals)-1]
for i := 1; i < len(cfg.AggregationIntervals); i++ {
ivl := cfg.AggregationIntervals[i]
if ivl%lowest != 0 {
return errors.New("aggregation intervals must be a factor of lowest interval")
}
}
// For encoding/decoding the processing time for combined metrics we only
// consider seconds granularity making 1 sec the lowest possible
// aggregation interval. We also encode interval as 2 unsigned bytes making
// 65535 (~18 hours) the highest possible aggregation interval.
if lowest < time.Second {
return errors.New("aggregation interval less than one second is not supported")
}
if highest > 18*time.Hour {
return errors.New("aggregation interval greater than 18 hours is not supported")
}
return nil
}