models.go 1.0 KB

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