accounting

package
v1.116.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2024 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
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

View Source
var (
	// ErrInvalidArgument is returned when a function argument has an invalid
	// business domain value.
	ErrInvalidArgument = errs.Class("invalid argument")
	// ErrSystemOrNetError is returned when the used storage backend returns an
	// internal system or network error.
	ErrSystemOrNetError = errs.Class("accounting backend")
	// ErrKeyNotFound is returned when the key is not found in the cache.
	ErrKeyNotFound = errs.Class("key not found")
	// ErrUnexpectedValue is returned when an unexpected value according the
	// business domain is in the cache.
	ErrUnexpectedValue = errs.Class("unexpected value")
)
View Source
var ErrProjectLimitExceeded = errs.Class("project limit")

ErrProjectLimitExceeded is used when the configured limits of a project are reached.

View Source
var ErrProjectUsage = errs.Class("project usage")

ErrProjectUsage general error for project usage.

Functions

This section is empty.

Types

type BucketStorageTally

type BucketStorageTally struct {
	BucketName    string
	ProjectID     uuid.UUID
	IntervalStart time.Time

	ObjectCount int64

	TotalSegmentCount int64
	TotalBytes        int64

	MetadataSize int64
}

BucketStorageTally holds data about a bucket tally.

func (*BucketStorageTally) Bytes added in v1.34.1

func (s *BucketStorageTally) Bytes() int64

Bytes returns total bytes.

type BucketTally

type BucketTally struct {
	metabase.BucketLocation

	ObjectCount        int64
	PendingObjectCount int64
	TotalSegments      int64
	TotalBytes         int64

	MetadataSize int64
}

BucketTally contains information about aggregate data stored in a bucket.

func (*BucketTally) Bytes

func (s *BucketTally) Bytes() int64

Bytes returns total bytes.

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 `json:"projectID"`
	BucketName string    `json:"bucketName"`

	DefaultPlacement storj.PlacementConstraint `json:"defaultPlacement"`
	Location         string                    `json:"location"`

	Versioning            buckets.Versioning  `json:"versioning"`
	ObjectLockEnabled     bool                `json:"objectLockEnabled"`
	DefaultRetentionMode  storj.RetentionMode `json:"defaultRetentionMode"`
	DefaultRetentionDays  *int                `json:"defaultRetentionDays"`
	DefaultRetentionYears *int                `json:"defaultRetentionYears"`

	Storage      float64 `json:"storage"`
	Egress       float64 `json:"egress"`
	ObjectCount  int64   `json:"objectCount"`
	SegmentCount int64   `json:"segmentCount"`

	Since  time.Time `json:"since"`
	Before time.Time `json:"before"`
}

BucketUsage consist of total bucket usage for period.

type BucketUsageCursor added in v0.26.0

type BucketUsageCursor struct {
	Search string
	Limit  uint
	Page   uint
}

BucketUsageCursor holds info for bucket usage cursor pagination.

type BucketUsagePage added in v0.26.0

type BucketUsagePage struct {
	BucketUsages []BucketUsage `json:"bucketUsages"`

	Search string `json:"search"`
	Limit  uint   `json:"limit"`
	Offset uint64 `json:"offset"`

	PageCount   uint   `json:"pageCount"`
	CurrentPage uint   `json:"currentPage"`
	TotalCount  uint64 `json:"totalCount"`
}

BucketUsagePage represents bucket usage page result.

type BucketUsageRollup added in v0.26.0

type BucketUsageRollup struct {
	ProjectID  uuid.UUID `json:"projectID"`
	BucketName string    `json:"bucketName"`

	TotalStoredData float64 `json:"totalStoredData"`

	TotalSegments float64 `json:"totalSegments"`
	ObjectCount   float64 `json:"objectCount"`
	MetadataSize  float64 `json:"metadataSize"`

	RepairEgress float64 `json:"repairEgress"`
	GetEgress    float64 `json:"getEgress"`
	AuditEgress  float64 `json:"auditEgress"`

	Since  time.Time `json:"since"`
	Before time.Time `json:"before"`
}

BucketUsageRollup is total bucket usage info for certain period.

type Cache added in v0.24.0

type Cache interface {
	// GetProjectStorageUsage returns the project's storage usage.
	GetProjectStorageUsage(ctx context.Context, projectID uuid.UUID) (totalUsed int64, err error)
	// GetProjectBandwidthUsage returns the project's bandwidth usage.
	GetProjectBandwidthUsage(ctx context.Context, projectID uuid.UUID, now time.Time) (currentUsed int64, err error)
	// GetProjectStorageAndSegmentUsage returns the project's storage and segment usage.
	GetProjectStorageAndSegmentUsage(ctx context.Context, projectID uuid.UUID) (storage, segment int64, err error)
	// AddProjectSegmentUsageUpToLimit increases segment usage up to the limit.
	// If the limit is exceeded, the usage is not increased and accounting.ErrProjectLimitExceeded is returned.
	AddProjectSegmentUsageUpToLimit(ctx context.Context, projectID uuid.UUID, increment int64, segmentLimit int64) error
	// InsertProjectBandwidthUsage inserts a project bandwidth usage if it
	// doesn't exist. It returns true if it's inserted, otherwise false.
	InsertProjectBandwidthUsage(ctx context.Context, projectID uuid.UUID, value int64, ttl time.Duration, now time.Time) (inserted bool, _ error)
	// UpdateProjectBandwidthUsage updates the project's bandwidth usage increasing
	// it. The projectID is inserted to the increment when it doesn't exists,
	// hence this method will never return ErrKeyNotFound error's class.
	UpdateProjectBandwidthUsage(ctx context.Context, projectID uuid.UUID, increment int64, ttl time.Duration, now time.Time) error
	// AddProjectStorageUsageUpToLimit increases storage usage up to the limit.
	// If the limit is exceeded, the usage is not increased and accounting.ErrProjectLimitExceeded is returned.
	AddProjectStorageUsageUpToLimit(ctx context.Context, projectID uuid.UUID, increment int64, spaceLimit int64) error
	// UpdateProjectStorageAndSegmentUsage updates the project's storage and segment usage by increasing it.
	UpdateProjectStorageAndSegmentUsage(ctx context.Context, projectID uuid.UUID, storageIncrement, segmentIncrement int64) (err error)
	// GetAllProjectTotals return the total projects' storage and segments used space.
	GetAllProjectTotals(ctx context.Context) (map[uuid.UUID]Usage, error)
	// Close the client, releasing any open resources. Once it's called any other
	// method must be called.
	Close() error
}

Cache stores live information about project storage which has not yet been synced to ProjectAccounting.

All the implementations must follow the convention of returning errors of one of the classes defined in this package.

All the methods return:

ErrInvalidArgument: an implementation may return if some parameter contain a value which isn't accepted, nonetheless, not all the implementations impose the same constraints on them.

ErrSystemOrNetError: any method will return this if there is an error with the underlining system or the network.

ErrKeyNotFound: returned when a key is not found.

ErrUnexpectedValue: returned when a key or value stored in the underlying system isn't of the expected format or type according the business domain.

architecture: Database

type NodePaymentInfo added in v1.115.2

type NodePaymentInfo struct {
	NodeID storj.NodeID

	AtRestTotal    float64
	GetRepairTotal int64
	PutRepairTotal int64
	GetAuditTotal  int64
	PutTotal       int64
	GetTotal       int64
}

NodePaymentInfo contains data for a node payment information.

type ProjectAccounting

type ProjectAccounting interface {
	// SaveTallies saves the latest project info
	SaveTallies(ctx context.Context, intervalStart time.Time, bucketTallies map[metabase.BucketLocation]*BucketTally) error
	// GetTallies retrieves all tallies ordered by interval start desc
	GetTallies(ctx context.Context) ([]BucketTally, error)
	// CreateStorageTally creates a record for BucketStorageTally in the accounting DB table
	CreateStorageTally(ctx context.Context, tally BucketStorageTally) error
	// GetNonEmptyTallyBucketsInRange returns a list of bucket locations within the given range
	// whose most recent tally does not represent empty usage.
	GetNonEmptyTallyBucketsInRange(ctx context.Context, from, to metabase.BucketLocation, asOfSystemInterval time.Duration) ([]metabase.BucketLocation, error)
	// GetProjectSettledBandwidthTotal returns the sum of GET bandwidth usage settled for a projectID in the past time frame.
	GetProjectSettledBandwidthTotal(ctx context.Context, projectID uuid.UUID, from time.Time) (_ int64, err error)
	// GetProjectBandwidth returns project allocated bandwidth for the specified year, month and day.
	GetProjectBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int, asOfSystemInterval time.Duration) (int64, error)
	// GetProjectSettledBandwidth returns the used settled bandwidth for the specified year and month.
	GetProjectSettledBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, asOfSystemInterval time.Duration) (int64, error)
	// GetProjectDailyBandwidth returns bandwidth (allocated and settled) for the specified day.
	GetProjectDailyBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int) (int64, int64, int64, error)
	// DeleteProjectBandwidthBefore deletes project bandwidth rollups before the given time
	DeleteProjectBandwidthBefore(ctx context.Context, before time.Time) error
	// GetProjectDailyUsageByDateRange returns daily allocated, settled bandwidth and storage usage for the specified date range.
	GetProjectDailyUsageByDateRange(ctx context.Context, projectID uuid.UUID, from, to time.Time, crdbInterval time.Duration) (*ProjectDailyUsage, error)

	// UpdateProjectUsageLimit updates project usage limit.
	UpdateProjectUsageLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) error
	// UpdateProjectBandwidthLimit updates project bandwidth limit.
	UpdateProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) error
	// UpdateProjectSegmentLimit updates project segment limit.
	UpdateProjectSegmentLimit(ctx context.Context, projectID uuid.UUID, limit int64) error
	// GetProjectStorageLimit returns project storage usage limit.
	GetProjectStorageLimit(ctx context.Context, projectID uuid.UUID) (*int64, error)
	// GetProjectBandwidthLimit returns project bandwidth usage limit.
	GetProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID) (*int64, error)
	// GetProjectSegmentLimit returns the segment limit for a project ID.
	GetProjectSegmentLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)
	// GetProjectLimits returns all project limits including user specified usage and bandwidth limits.
	GetProjectLimits(ctx context.Context, projectID uuid.UUID) (ProjectLimits, error)
	// GetProjectTotal returns project usage summary for specified period of time.
	GetProjectTotal(ctx context.Context, projectID uuid.UUID, since, before time.Time) (*ProjectUsage, error)
	// GetProjectTotalByPartner retrieves project usage for a given period categorized by partner name.
	// Unpartnered usage or usage for a partner not present in partnerNames is mapped to the empty string.
	GetProjectTotalByPartner(ctx context.Context, projectID uuid.UUID, partnerNames []string, since, before time.Time) (usages map[string]ProjectUsage, err error)
	// GetProjectObjectsSegments returns project objects and segments number.
	GetProjectObjectsSegments(ctx context.Context, projectID uuid.UUID) (ProjectObjectsSegments, 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)
	// GetSingleBucketUsageRollup returns usage rollup per single bucket for specified period of time.
	GetSingleBucketUsageRollup(ctx context.Context, projectID uuid.UUID, bucket string, since, before time.Time) (*BucketUsageRollup, error)
	// GetSingleBucketTotals returns single bucket total usage summary since bucket creation.
	GetSingleBucketTotals(ctx context.Context, projectID uuid.UUID, bucketName string, before time.Time) (usage *BucketUsage, err error)
	// GetBucketTotals returns per bucket total usage summary since bucket creation.
	GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor BucketUsageCursor, before time.Time) (*BucketUsagePage, error)
	// ArchiveRollupsBefore archives rollups older than a given time and returns number of bucket bandwidth rollups archived.
	ArchiveRollupsBefore(ctx context.Context, before time.Time, batchSize int) (numArchivedBucketBW int, err error)
	// GetRollupsSince retrieves all archived bandwidth rollup records since a given time. A hard limit batch size is used for results.
	GetRollupsSince(ctx context.Context, since time.Time) ([]orders.BucketBandwidthRollup, error)
	// GetArchivedRollupsSince retrieves all archived bandwidth rollup records since a given time. A hard limit batch size is used for results.
	GetArchivedRollupsSince(ctx context.Context, since time.Time) ([]orders.BucketBandwidthRollup, error)
}

ProjectAccounting stores information about bandwidth and storage usage for projects.

architecture: Database

type ProjectDailyUsage added in v1.48.1

type ProjectDailyUsage struct {
	StorageUsage            []ProjectUsageByDay `json:"storageUsage"`
	AllocatedBandwidthUsage []ProjectUsageByDay `json:"allocatedBandwidthUsage"`
	SettledBandwidthUsage   []ProjectUsageByDay `json:"settledBandwidthUsage"`
}

ProjectDailyUsage holds project daily usage.

type ProjectLimits added in v1.14.1

type ProjectLimits struct {
	ProjectID        uuid.UUID
	Usage            *int64
	UserSetUsage     *int64
	Bandwidth        *int64
	UserSetBandwidth *int64
	Segments         *int64

	RateLimit        *int
	BurstLimit       *int
	RateLimitHead    *int
	BurstLimitHead   *int
	RateLimitGet     *int
	BurstLimitGet    *int
	RateLimitPut     *int
	BurstLimitPut    *int
	RateLimitList    *int
	BurstLimitList   *int
	RateLimitDelete  *int
	BurstLimitDelete *int
}

ProjectLimits contains the project limits.

type ProjectObjectsSegments added in v1.45.2

type ProjectObjectsSegments struct {
	SegmentCount int64 `json:"segmentCount"`
	ObjectCount  int64 `json:"objectCount"`
}

ProjectObjectsSegments consist of period total objects and segments count for certain Project.

type ProjectReportItem added in v1.93.1

type ProjectReportItem struct {
	ProjectID   uuid.UUID
	ProjectName string

	BucketName   string
	Storage      float64
	Egress       float64
	SegmentCount float64
	ObjectCount  float64

	Since  time.Time `json:"since"`
	Before time.Time `json:"before"`
}

ProjectReportItem is total bucket usage info with project details for certain period.

func (*ProjectReportItem) ToStringSlice added in v1.93.1

func (b *ProjectReportItem) ToStringSlice() []string

ToStringSlice converts report item values to a slice of strings.

type ProjectUsage

type ProjectUsage struct {
	Storage      float64 `json:"storage"`
	Egress       int64   `json:"egress"`
	SegmentCount float64 `json:"segmentCount"`
	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 ProjectUsageByDay added in v1.48.1

type ProjectUsageByDay struct {
	Date  time.Time `json:"date"`
	Value int64     `json:"value"`
}

ProjectUsageByDay holds project daily usage.

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
	IntervalEndTime time.Time
}

Rollup mirrors dbx.AccountingRollup, allowing us to use that struct without leaking dbx.

type RollupStats

type RollupStats map[time.Time]map[storj.NodeID]*Rollup

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(log *zap.Logger, projectAccountingDB ProjectAccounting, liveAccounting Cache, metabaseDB metabase.DB, bandwidthCacheTTL time.Duration,
	defaultMaxStorage, defaultMaxBandwidth memory.Size, defaultMaxSegments int64, asOfSystemInterval time.Duration) *Service

NewService created new instance of project usage service.

func (*Service) AddProjectUsageUpToLimit added in v1.61.1

func (usage *Service) AddProjectUsageUpToLimit(ctx context.Context, projectID uuid.UUID, storage int64, segments int64, limits ProjectLimits) (err error)

AddProjectUsageUpToLimit increases segment and storage usage up to the projects limit. If the limit is exceeded, neither usage is increased and accounting.ErrProjectLimitExceeded is returned.

func (*Service) ExceedsBandwidthUsage added in v0.26.0

func (usage *Service) ExceedsBandwidthUsage(ctx context.Context, limits ProjectLimits) (exceeds 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.

Among others,it can return one of the following errors returned by storj.io/storj/satellite/accounting.Cache except the ErrKeyNotFound, wrapped by ErrProjectUsage.

func (*Service) ExceedsUploadLimits added in v1.47.3

func (usage *Service) ExceedsUploadLimits(
	ctx context.Context, storageSizeHeadroom int64, segmentCountHeadroom int64, limits ProjectLimits) (limit UploadLimit)

ExceedsUploadLimits returns combined checks for storage and segment limits. Supply nonzero headroom parameters to check if there is room for a new object.

func (*Service) GetProjectBandwidth added in v1.31.1

func (usage *Service) GetProjectBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int) (_ int64, err error)

GetProjectBandwidth returns project allocated bandwidth for the specified year, month and day.

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) GetProjectBandwidthUsage added in v1.7.1

func (usage *Service) GetProjectBandwidthUsage(ctx context.Context, projectID uuid.UUID) (currentUsed int64, err error)

GetProjectBandwidthUsage get the current bandwidth usage from cache.

It can return one of the following errors returned by storj.io/storj/satellite/accounting.Cache.GetProjectBandwidthUsage, wrapped by ErrProjectUsage.

func (*Service) GetProjectLimits added in v1.106.1

func (usage *Service) GetProjectLimits(ctx context.Context, projectID uuid.UUID) (_ *ProjectLimits, err error)

GetProjectLimits returns all project limits including user specified usage and bandwidth limits.

func (*Service) GetProjectSegmentLimit added in v1.45.2

func (usage *Service) GetProjectSegmentLimit(ctx context.Context, projectID uuid.UUID) (_ memory.Size, err error)

GetProjectSegmentLimit returns current project segment limit.

func (*Service) GetProjectSettledBandwidth added in v1.83.2

func (usage *Service) GetProjectSettledBandwidth(ctx context.Context, projectID uuid.UUID) (_ int64, err error)

GetProjectSettledBandwidth returns total amount of settled bandwidth used for past 30 days.

func (*Service) GetProjectStorageAndSegmentUsage added in v1.106.1

func (usage *Service) GetProjectStorageAndSegmentUsage(ctx context.Context, projectID uuid.UUID) (storage, segments int64, err error)

GetProjectStorageAndSegmentUsage get the current storage and segment usage from cache.

It can return one of the following errors returned by storj.io/storj/satellite/accounting.Cache.GetProjectStorageAndSegmentUsage.

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.

func (*Service) GetProjectStorageTotals added in v0.28.0

func (usage *Service) GetProjectStorageTotals(ctx context.Context, projectID uuid.UUID) (total int64, err error)

GetProjectStorageTotals returns total amount of storage used by project.

It can return one of the following errors returned by storj.io/storj/satellite/accounting.Cache.GetProjectStorageUsage except the ErrKeyNotFound, wrapped by ErrProjectUsage.

func (*Service) SetNow added in v1.4.3

func (usage *Service) SetNow(now func() time.Time)

SetNow allows tests to have the Service act as if the current time is whatever they want.

func (*Service) TestSetAsOfSystemInterval added in v1.85.1

func (usage *Service) TestSetAsOfSystemInterval(asOfSystemInterval time.Duration)

TestSetAsOfSystemInterval allows tests to set Service asOfSystemInterval value.

func (*Service) UpdateProjectBandwidthUsage added in v1.7.1

func (usage *Service) UpdateProjectBandwidthUsage(ctx context.Context, limits ProjectLimits, increment int64) (err error)

UpdateProjectBandwidthUsage increments the bandwidth cache key for a specific project.

It can return one of the following errors returned by storj.io/storj/satellite/accounting.Cache.UpdateProjectBandwidthUsage, wrapped by ErrProjectUsage.

func (*Service) UpdateProjectStorageAndSegmentUsage added in v1.106.1

func (usage *Service) UpdateProjectStorageAndSegmentUsage(ctx context.Context, limits ProjectLimits, storageIncr, segmentIncr int64) (err error)

UpdateProjectStorageAndSegmentUsage increments the storage and segment cache keys for a specific project.

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

type StorageNodeUsage struct {
	NodeID      storj.NodeID
	StorageUsed float64

	Timestamp       time.Time
	IntervalEndTime time.Time
}

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, nodes []storj.NodeID, tallies []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, cb func(context.Context, *StoragenodeBandwidthRollup) error) 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 accounting information and different usage.
	QueryPaymentInfo(ctx context.Context, start time.Time, end time.Time) ([]NodePaymentInfo, 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, batchSize int) error
	// ArchiveRollupsBefore archives rollups older than a given time and returns num storagenode and bucket bandwidth rollups archived.
	ArchiveRollupsBefore(ctx context.Context, before time.Time, batchSize int) (numArchivedNodeBW int, err error)
	// GetRollupsSince retrieves all archived bandwidth rollup records since a given time. A hard limit batch size is used for results.
	GetRollupsSince(ctx context.Context, since time.Time) ([]StoragenodeBandwidthRollup, error)
	// GetArchivedRollupsSince retrieves all archived bandwidth rollup records since a given time. A hard limit batch size is used for results.
	GetArchivedRollupsSince(ctx context.Context, since time.Time) ([]StoragenodeBandwidthRollup, error)
}

StoragenodeAccounting stores information about bandwidth and storage usage for storage nodes.

architecture: Database

type StoragenodeBandwidthRollup

type StoragenodeBandwidthRollup struct {
	NodeID        storj.NodeID
	IntervalStart time.Time
	Action        uint
	Settled       uint64
}

StoragenodeBandwidthRollup mirrors dbx.StoragenodeBandwidthRollup, allowing us to use the struct without leaking dbx.

type StoragenodeStorageTally

type StoragenodeStorageTally struct {
	ID              int64
	NodeID          storj.NodeID
	IntervalEndTime time.Time
	DataTotal       float64
}

StoragenodeStorageTally mirrors dbx.StoragenodeStorageTally, allowing us to use that struct without leaking dbx.

type UploadLimit added in v1.47.3

type UploadLimit struct {
	ExceedsStorage  bool
	StorageLimit    memory.Size
	ExceedsSegments bool
	SegmentsLimit   int64
}

UploadLimit contains upload limit characteristics.

type Usage added in v1.55.1

type Usage struct {
	Storage  int64
	Segments int64
}

Usage contains project's usage split on segments and storage.

Directories

Path Synopsis
Package live provides live accounting functionality.
Package live provides live accounting functionality.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL