test_tstorage.go 549 B

1234567891011121314151617181920212223242526
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/nakabonne/tstorage"
  5. )
  6. func main() {
  7. storage, _ := tstorage.NewStorage(
  8. tstorage.WithTimestampPrecision(tstorage.Seconds),
  9. )
  10. defer storage.Close()
  11. _ = storage.InsertRows([]tstorage.Row{
  12. {
  13. Metric: "metric1",
  14. DataPoint: tstorage.DataPoint{Timestamp: 1600000000, Value: 0.1},
  15. },
  16. })
  17. points, _ := storage.Select("metric1", nil, 1600000000, 1600000001)
  18. for _, p := range points {
  19. fmt.Printf("timestamp: %v, value: %v\n", p.Timestamp, p.Value)
  20. // => timestamp: 1600000000, value: 0.1
  21. }
  22. }