mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Rename RecordStatesAsync to Record * Rename QueryStates to Query * Implement fanout writes * Implement primary queries * Simplify error joining * Add test for query path * Add tests for writes and error propagation * Allow fanout backend to be configured * Touch up log messages and config validation * Consistent documentation for all backend structs * Parse and normalize backend names more consistently against an enum * Touch-ups to documentation * Improve clarity around multi-record blocking * Keep primary and secondaries more distinct * Rename fanout backend to multiple backend * Simplify config keys for multi backend mode
40 lines
932 B
Go
40 lines
932 B
Go
package historian
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// BackendType identifies different kinds of state history backends.
|
|
type BackendType string
|
|
|
|
// String implements Stringer for BackendType.
|
|
func (bt BackendType) String() string {
|
|
return string(bt)
|
|
}
|
|
|
|
const (
|
|
BackendTypeAnnotations BackendType = "annotations"
|
|
BackendTypeLoki BackendType = "loki"
|
|
BackendTypeMultiple BackendType = "multiple"
|
|
BackendTypeNoop BackendType = "noop"
|
|
BackendTypeSQL BackendType = "sql"
|
|
)
|
|
|
|
func ParseBackendType(s string) (BackendType, error) {
|
|
norm := strings.ToLower(strings.TrimSpace(s))
|
|
|
|
types := map[BackendType]struct{}{
|
|
BackendTypeAnnotations: {},
|
|
BackendTypeLoki: {},
|
|
BackendTypeMultiple: {},
|
|
BackendTypeNoop: {},
|
|
BackendTypeSQL: {},
|
|
}
|
|
p := BackendType(norm)
|
|
if _, ok := types[p]; !ok {
|
|
return "", fmt.Errorf("unrecognized state history backend: %s", p)
|
|
}
|
|
return p, nil
|
|
}
|