Repository: influxdata/influxdb
File: tsdb/config.go (Go)

Code before:
	}

	valid := false
	for _, e := range RegisteredEngines() {
		if e == c.Engine {
			valid = true
			break
		}
	}
	if !valid {
		return fmt.Errorf("unrecognized engine %s", c.Engine)
	}

	valid = false
	for _, e := range RegisteredIndexes() {
		if e == c.Index {
			valid = true
			break
		}
	}
	if !valid {
		return fmt.Errorf("unrecognized index %s", c.Index)
	}

	if c.TarStreamBufferSize <= 0 {
		return fmt.Errorf("tar-stream-buffer-size cannot be zero and must be non-negative")
	}

	return nil
}

// Diagnostics returns a diagnostics representation of a subset of the Config.
func (c Config) Diagnostics() (*diagnostics.Diagnostics, error) {
	return diagnostics.RowFromMap(map[string]interface{}{
		"dir":                                    c.Dir,
		"wal-dir":                                c.WALDir,
		"wal-fsync-delay":                        c.WALFsyncDelay,
		"strict-error-handling":                  c.StrictErrorHandling,
		"cache-max-memory-size":                  c.CacheMaxMemorySize,
		"cache-snapshot-memory-size":             c.CacheSnapshotMemorySize,
		"cache-snapshot-write-cold-duration":     c.CacheSnapshotWriteColdDuration,
		"compact-full-write-cold-duration":       c.CompactFullWriteColdDuration,
		"max-series-per-database":                c.MaxSeriesPerDatabase,
		"max-values-per-tag":                     c.MaxValuesPerTag,
		"max-concurrent-compactions":             c.MaxConcurrentCompactions,
		"max-index-log-file-size":                c.MaxIndexLogFileSize,
		"series-id-set-cache-size":               c.SeriesIDSetCacheSize,
		"series-file-max-concurrent-compactions": c.SeriesFileMaxConcurrentSnapshotCompactions,
		"aggressive-points-per-block":            c.AggressivePointsPerBlock,
		"compact-throughput":                     c.CompactThroughput,
		"compact-throughput-burst":               c.CompactThroughputBurst,

Review comment (bug):
Put the erroneous value in the error with a `%d` to help debug problems.

Code after:
	}

	valid := false
	for _, e := range RegisteredEngines() {
		if e == c.Engine {
			valid = true
			break
		}
	}
	if !valid {
		return fmt.Errorf("unrecognized engine %s", c.Engine)
	}

	valid = false
	for _, e := range RegisteredIndexes() {
		if e == c.Index {
			valid = true
			break
		}
	}
	if !valid {
		return fmt.Errorf("unrecognized index %s", c.Index)
	}

	if c.TarStreamBufferSize <= 0 {
		return fmt.Errorf("tar-stream-buffer-size cannot be %d, value must be greater than zero and non-negative", c.TarStreamBufferSize)
	}

	return nil
}

// Diagnostics returns a diagnostics representation of a subset of the Config.
func (c Config) Diagnostics() (*diagnostics.Diagnostics, error) {
	return diagnostics.RowFromMap(map[string]interface{}{
		"dir":                                    c.Dir,
		"wal-dir":                                c.WALDir,
		"wal-fsync-delay":                        c.WALFsyncDelay,
		"strict-error-handling":                  c.StrictErrorHandling,
		"cache-max-memory-size":                  c.CacheMaxMemorySize,
		"cache-snapshot-memory-size":             c.CacheSnapshotMemorySize,
		"cache-snapshot-write-cold-duration":     c.CacheSnapshotWriteColdDuration,
		"compact-full-write-cold-duration":       c.CompactFullWriteColdDuration,
		"max-series-per-database":                c.MaxSeriesPerDatabase,
		"max-values-per-tag":                     c.MaxValuesPerTag,
		"max-concurrent-compactions":             c.MaxConcurrentCompactions,
		"max-index-log-file-size":                c.MaxIndexLogFileSize,
		"series-id-set-cache-size":               c.SeriesIDSetCacheSize,
		"series-file-max-concurrent-compactions": c.SeriesFileMaxConcurrentSnapshotCompactions,
		"aggressive-points-per-block":            c.AggressivePointsPerBlock,
		"compact-throughput":                     c.CompactThroughput,
		"compact-throughput-burst":               c.CompactThroughputBurst,