source.go 807 B

12345678910111213141516171819
  1. package exporter
  2. import "time"
  3. // ComputeSource[T] provides an interface for a compute data source.
  4. type ComputeSource[T any] interface {
  5. // CanCompute should return true iff the ComputeSource can effectively act as
  6. // a source of T data for the given time range. For example, a ComputeSource
  7. // with two-day coverage cannot fulfill a range from three days ago, and should
  8. // not be left to return an error in Compute. Instead, it should report that is
  9. // cannot compute and allow another Source to handle the computation.
  10. CanCompute(start, end time.Time) bool
  11. // Compute should compute a single T for the given time range, optionally using the given resolution.
  12. Compute(start, end time.Time, resolution time.Duration) (*T, error)
  13. // Name returns the name of the ComputeSource
  14. Name() string
  15. }