Documentation ¶
Index ¶
- Constants
- Variables
- type BucketStorageTally
- type BucketTally
- type BucketUsage
- type BucketUsageCursor
- type BucketUsagePage
- type BucketUsageRollup
- type CSVRow
- type Cache
- type ProjectAccounting
- type ProjectUsage
- type Rollup
- type RollupStats
- type Service
- func (usage *Service) AddProjectStorageUsage(ctx context.Context, projectID uuid.UUID, spaceUsed int64) (err error)
- func (usage *Service) ExceedsBandwidthUsage(ctx context.Context, projectID uuid.UUID, bucketID []byte) (_ bool, limit memory.Size, err error)
- func (usage *Service) ExceedsStorageUsage(ctx context.Context, projectID uuid.UUID) (_ bool, limit memory.Size, err error)
- func (usage *Service) GetCurrentBandwidthAllocated(ctx context.Context, projectID uuid.UUID) (_ int64, err error)
- func (usage *Service) GetProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error)
- func (usage *Service) GetProjectBandwidthTotals(ctx context.Context, projectID uuid.UUID) (_ int64, err error)
- func (usage *Service) GetProjectStorageLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error)
- func (usage *Service) GetProjectStorageTotals(ctx context.Context, projectID uuid.UUID) (total int64, err error)
- func (usage *Service) UpdateProjectLimits(ctx context.Context, projectID uuid.UUID, limit memory.Size) (err error)
- type StorageNodePeriodUsage
- type StorageNodeUsage
- type StoragenodeAccounting
- type StoragenodeBandwidthRollup
- type StoragenodeStorageTally
Constants ¶
const ( // LastAtRestTally represents the accounting timestamp for the at-rest data calculation LastAtRestTally = "LastAtRestTally" // LastBandwidthTally represents the accounting timestamp for the bandwidth allocation query LastBandwidthTally = "LastBandwidthTally" // LastRollup represents the accounting timestamp for rollup calculations LastRollup = "LastRollup" )
Constants for accounting_raw, accounting_rollup, and accounting_timestamps
Variables ¶
var ( // ErrProjectUsage general error for project usage ErrProjectUsage = errs.Class("project usage error") )
Functions ¶
This section is empty.
Types ¶
type BucketStorageTally ¶
type BucketStorageTally struct { BucketName string ProjectID uuid.UUID IntervalStart time.Time ObjectCount int64 InlineSegmentCount int64 RemoteSegmentCount int64 InlineBytes int64 RemoteBytes int64 MetadataSize int64 }
BucketStorageTally holds data about a bucket tally
type BucketTally ¶
type BucketTally struct { ProjectID uuid.UUID BucketName []byte ObjectCount int64 InlineSegments int64 RemoteSegments int64 InlineBytes int64 RemoteBytes int64 MetadataSize int64 }
BucketTally contains information about aggregate data stored in a bucket
func (*BucketTally) Combine ¶
func (s *BucketTally) Combine(o *BucketTally)
Combine aggregates all the tallies
func (*BucketTally) Segments ¶
func (s *BucketTally) Segments() int64
Segments returns total number of segments.
type BucketUsage ¶
type BucketUsage struct { ProjectID uuid.UUID BucketName string Storage float64 Egress float64 ObjectCount int64 Since time.Time Before time.Time }
BucketUsage consist of total bucket usage for period
type BucketUsageCursor ¶ added in v0.26.0
BucketUsageCursor holds info for bucket usage cursor pagination
type BucketUsagePage ¶ added in v0.26.0
type BucketUsagePage struct { BucketUsages []BucketUsage Search string Limit uint Offset uint64 PageCount uint CurrentPage uint TotalCount uint64 }
BucketUsagePage represents bucket usage page result
type BucketUsageRollup ¶ added in v0.26.0
type BucketUsageRollup struct { ProjectID uuid.UUID BucketName []byte RemoteStoredData float64 InlineStoredData float64 RemoteSegments float64 InlineSegments float64 ObjectCount float64 MetadataSize float64 RepairEgress float64 GetEgress float64 AuditEgress float64 Since time.Time Before time.Time }
BucketUsageRollup is total bucket usage info for certain period
type CSVRow ¶
type CSVRow struct { NodeID storj.NodeID NodeCreationDate time.Time AtRestTotal float64 GetRepairTotal int64 PutRepairTotal int64 GetAuditTotal int64 PutTotal int64 GetTotal int64 Wallet string Disqualified *time.Time }
CSVRow represents data from QueryPaymentInfo without exposing dbx
type Cache ¶ added in v0.24.0
type Cache interface { GetProjectStorageUsage(ctx context.Context, projectID uuid.UUID) (totalUsed int64, err error) AddProjectStorageUsage(ctx context.Context, projectID uuid.UUID, spaceUsed int64) error GetAllProjectTotals(ctx context.Context) (map[uuid.UUID]int64, error) Close() error }
Cache stores live information about project storage which has not yet been synced to ProjectAccounting.
architecture: Database
type ProjectAccounting ¶
type ProjectAccounting interface { // SaveTallies saves the latest project info SaveTallies(ctx context.Context, intervalStart time.Time, bucketTallies map[string]*BucketTally) error // GetTallies retrieves all tallies GetTallies(ctx context.Context) ([]BucketTally, error) // CreateStorageTally creates a record for BucketStorageTally in the accounting DB table CreateStorageTally(ctx context.Context, tally BucketStorageTally) error // GetAllocatedBandwidthTotal returns the sum of GET bandwidth usage allocated for a projectID in the past time frame GetAllocatedBandwidthTotal(ctx context.Context, projectID uuid.UUID, from time.Time) (int64, error) // GetCurrentBandwidthAllocated returns allocated bandwidth for the current month GetCurrentBandwidthAllocated(ctx context.Context, projectID uuid.UUID) (int64, error) // GetStorageTotals returns the current inline and remote storage usage for a projectID GetStorageTotals(ctx context.Context, projectID uuid.UUID) (int64, int64, error) // UpdateProjectUsageLimit updates project usage limit. UpdateProjectUsageLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) error // GetProjectStorageLimit returns project storage usage limit. GetProjectStorageLimit(ctx context.Context, projectID uuid.UUID) (memory.Size, error) // GetProjectBandwidthLimit returns project bandwidth usage limit. GetProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID) (memory.Size, error) // GetProjectTotal returns project usage summary for specified period of time. GetProjectTotal(ctx context.Context, projectID uuid.UUID, since, before time.Time) (*ProjectUsage, error) // GetBucketUsageRollups returns usage rollup per each bucket for specified period of time. GetBucketUsageRollups(ctx context.Context, projectID uuid.UUID, since, before time.Time) ([]BucketUsageRollup, error) // GetBucketTotals returns per bucket usage summary for specified period of time. GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor BucketUsageCursor, since, before time.Time) (*BucketUsagePage, error) }
ProjectAccounting stores information about bandwidth and storage usage for projects
architecture: Database
type ProjectUsage ¶
type ProjectUsage struct { Storage float64 `json:"storage"` Egress int64 `json:"egress"` ObjectCount float64 `json:"objectCount"` Since time.Time `json:"since"` Before time.Time `json:"before"` }
ProjectUsage consist of period total storage, egress and objects count per hour for certain Project in bytes
type Rollup ¶
type Rollup struct { ID int64 NodeID storj.NodeID StartTime time.Time PutTotal int64 GetTotal int64 GetAuditTotal int64 GetRepairTotal int64 PutRepairTotal int64 AtRestTotal float64 }
Rollup mirrors dbx.AccountingRollup, allowing us to use that struct without leaking dbx
type RollupStats ¶
RollupStats is a convenience alias
type Service ¶ added in v0.26.0
type Service struct {
// contains filtered or unexported fields
}
Service is handling project usage related logic.
architecture: Service
func NewService ¶ added in v0.26.0
func NewService(projectAccountingDB ProjectAccounting, liveAccounting Cache, maxAlphaUsage memory.Size) *Service
NewService created new instance of project usage service.
func (*Service) AddProjectStorageUsage ¶ added in v0.26.0
func (usage *Service) AddProjectStorageUsage(ctx context.Context, projectID uuid.UUID, spaceUsed int64) (err error)
AddProjectStorageUsage lets the live accounting know that the given project has just added spaceUsed bytes of storage (from the user's perspective; i.e. segment size).
func (*Service) ExceedsBandwidthUsage ¶ added in v0.26.0
func (usage *Service) ExceedsBandwidthUsage(ctx context.Context, projectID uuid.UUID, bucketID []byte) (_ bool, limit memory.Size, err error)
ExceedsBandwidthUsage returns true if the bandwidth usage limits have been exceeded for a project in the past month (30 days). The usage limit is (e.g 25GB) multiplied by the redundancy expansion factor, so that the uplinks have a raw limit. Ref: https://storjlabs.atlassian.net/browse/V3-1274
func (*Service) ExceedsStorageUsage ¶ added in v0.26.0
func (usage *Service) ExceedsStorageUsage(ctx context.Context, projectID uuid.UUID) (_ bool, limit memory.Size, err error)
ExceedsStorageUsage returns true if the storage usage for a project is currently over that project's limit.
func (*Service) GetCurrentBandwidthAllocated ¶ added in v1.4.1
func (usage *Service) GetCurrentBandwidthAllocated(ctx context.Context, projectID uuid.UUID) (_ int64, err error)
GetCurrentBandwidthAllocated returns allocated bandwidth for the current month
func (*Service) GetProjectBandwidthLimit ¶ added in v0.28.0
func (usage *Service) GetProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error)
GetProjectBandwidthLimit returns current project bandwidth limit.
func (*Service) GetProjectBandwidthTotals ¶ added in v0.28.0
func (usage *Service) GetProjectBandwidthTotals(ctx context.Context, projectID uuid.UUID) (_ int64, err error)
GetProjectBandwidthTotals returns total amount of allocated bandwidth used for past 30 days.
func (*Service) GetProjectStorageLimit ¶ added in v0.28.0
func (usage *Service) GetProjectStorageLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error)
GetProjectStorageLimit returns current project storage limit.
type StorageNodePeriodUsage ¶ added in v1.1.1
type StorageNodePeriodUsage struct { NodeID storj.NodeID AtRestTotal float64 GetTotal int64 PutTotal int64 GetRepairTotal int64 PutRepairTotal int64 GetAuditTotal int64 }
StorageNodePeriodUsage represents a statement for a node for a compensation period
type StorageNodeUsage ¶ added in v0.18.0
StorageNodeUsage is node at rest space usage over a period of time
type StoragenodeAccounting ¶
type StoragenodeAccounting interface { // SaveTallies records tallies of data at rest SaveTallies(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]float64) error // GetTallies retrieves all tallies GetTallies(ctx context.Context) ([]*StoragenodeStorageTally, error) // GetTalliesSince retrieves all tallies since latestRollup GetTalliesSince(ctx context.Context, latestRollup time.Time) ([]*StoragenodeStorageTally, error) // GetBandwidthSince retrieves all bandwidth rollup entires since latestRollup GetBandwidthSince(ctx context.Context, latestRollup time.Time) ([]*StoragenodeBandwidthRollup, error) // SaveRollup records tally and bandwidth rollup aggregations to the database SaveRollup(ctx context.Context, latestTally time.Time, stats RollupStats) error // LastTimestamp records and returns the latest last tallied time. LastTimestamp(ctx context.Context, timestampType string) (time.Time, error) // QueryPaymentInfo queries Nodes and Accounting_Rollup on nodeID QueryPaymentInfo(ctx context.Context, start time.Time, end time.Time) ([]*CSVRow, error) // QueryStorageNodePeriodUsage returns accounting statements for nodes for a given compensation period QueryStorageNodePeriodUsage(ctx context.Context, period compensation.Period) ([]StorageNodePeriodUsage, error) // QueryStorageNodeUsage returns slice of StorageNodeUsage for given period QueryStorageNodeUsage(ctx context.Context, nodeID storj.NodeID, start time.Time, end time.Time) ([]StorageNodeUsage, error) // DeleteTalliesBefore deletes all tallies prior to some time DeleteTalliesBefore(ctx context.Context, latestRollup time.Time) error }
StoragenodeAccounting stores information about bandwidth and storage usage for storage nodes
architecture: Database
Directories ¶
Path | Synopsis |
---|---|
Package live provides live accounting functionality.
|
Package live provides live accounting functionality. |