2019-08-08 14:47:04 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package storageusage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/storj"
|
2019-08-08 14:47:04 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// DB works with storage usage database
|
2019-09-10 14:24:16 +01:00
|
|
|
//
|
|
|
|
// architecture: Database
|
2019-08-08 14:47:04 +01:00
|
|
|
type DB interface {
|
|
|
|
// Store stores storage usage stamps to db replacing conflicting entries
|
|
|
|
Store(ctx context.Context, stamps []Stamp) error
|
|
|
|
// GetDaily returns daily storage usage stamps for particular satellite
|
|
|
|
// for provided time range
|
|
|
|
GetDaily(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) ([]Stamp, error)
|
|
|
|
// GetDailyTotal returns daily storage usage stamps summed across all known satellites
|
|
|
|
// for provided time range
|
|
|
|
GetDailyTotal(ctx context.Context, from, to time.Time) ([]Stamp, error)
|
2019-09-04 15:13:43 +01:00
|
|
|
// Summary returns aggregated storage usage across all satellites.
|
|
|
|
Summary(ctx context.Context, from, to time.Time) (float64, error)
|
|
|
|
// SatelliteSummary returns aggregated storage usage for a particular satellite.
|
|
|
|
SatelliteSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (float64, error)
|
2019-08-08 14:47:04 +01:00
|
|
|
}
|
|
|
|
|
2019-09-04 15:13:43 +01:00
|
|
|
// Stamp is storage usage stamp for satellite from interval start till next interval.
|
2019-08-08 14:47:04 +01:00
|
|
|
type Stamp struct {
|
2019-09-04 15:13:43 +01:00
|
|
|
SatelliteID storj.NodeID `json:"-"`
|
|
|
|
AtRestTotal float64 `json:"atRestTotal"`
|
|
|
|
IntervalStart time.Time `json:"intervalStart"`
|
2019-08-08 14:47:04 +01:00
|
|
|
}
|