storj/satellite/accounting/bucketusage.go
Michał Niewrzał 0ca7583282 satellite/accounting: add total for bytes and segments to tallies
We want to calculate bucket tally only from iterating objects.
Object currently has an info about totals for bytes and segments.
We need to adjust tallies to keep those totals. Older entries will
be untouched and code will use totals only if available. Change
is adding columns for totals to bucket_storage_tally table and
is adding general handling for them.

Next step is to start using total columns instead of inline/remote.
This will be done with next change.

Change-Id: I37fed1b327789efcf1d0570318aee3045db17fad
2021-07-01 08:52:32 +00:00

37 lines
652 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package accounting
import (
"time"
"storj.io/common/uuid"
)
// BucketStorageTally holds data about a bucket tally.
type BucketStorageTally struct {
BucketName string
ProjectID uuid.UUID
IntervalStart time.Time
ObjectCount int64
TotalSegmentCount int64
InlineSegmentCount int64
RemoteSegmentCount int64
TotalBytes int64
InlineBytes int64
RemoteBytes int64
MetadataSize int64
}
// Bytes returns total bytes.
func (s *BucketStorageTally) Bytes() int64 {
if s.TotalBytes != 0 {
return s.TotalBytes
}
return s.InlineBytes + s.RemoteBytes
}