models.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package tsdb
  2. type TimeRange struct {
  3. From string
  4. To string
  5. }
  6. type Request struct {
  7. TimeRange TimeRange
  8. MaxDataPoints int
  9. Queries QuerySlice
  10. }
  11. type Response struct {
  12. BatchTimings []*BatchTiming
  13. Results map[string]*QueryResult
  14. }
  15. type DataSourceInfo struct {
  16. Id int64
  17. Name string
  18. PluginId string
  19. Url string
  20. Password string
  21. User string
  22. Database string
  23. BasicAuth bool
  24. BasicAuthUser string
  25. BasicAuthPassword string
  26. }
  27. type BatchTiming struct {
  28. TimeElapsed int64
  29. }
  30. type BatchResult struct {
  31. Error error
  32. QueryResults map[string]*QueryResult
  33. Timings *BatchTiming
  34. }
  35. type QueryResult struct {
  36. Error error
  37. RefId string
  38. Series TimeSeriesSlice
  39. }
  40. type TimeSeries struct {
  41. Name string `json:"name"`
  42. Points [][2]float64 `json:"points"`
  43. }
  44. type TimeSeriesSlice []*TimeSeries
  45. func NewTimeSeries(name string, points [][2]float64) *TimeSeries {
  46. return &TimeSeries{
  47. Name: name,
  48. Points: points,
  49. }
  50. }