satellitedb

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: AGPL-3.0 Imports: 52 Imported by: 4

Documentation

Index

Constants

View Source
const RepairQueueSelectLimit = 1000

RepairQueueSelectLimit defines how many items can be selected at the same time.

Variables

View Source
var (
	// ErrMigrate is for tracking migration errors.
	ErrMigrate = errs.Class("migrate")
	// ErrMigrateMinVersion is for migration min version errors.
	ErrMigrateMinVersion = errs.Class("migrate min version")
)
View Source
var (
	// ErrDifferentStorageNodes is returned when ProcessOrders gets orders from different storage nodes.
	ErrDifferentStorageNodes = errs.Class("different storage nodes")
	// ErrBucketFromSerial is returned when there is an error trying to get the bucket name from the serial number.
	ErrBucketFromSerial = errs.Class("bucket from serial number")
	// ErrUpdateBucketBandwidthSettle is returned when there is an error updating bucket bandwidth.
	ErrUpdateBucketBandwidthSettle = errs.Class("update bucket bandwidth settle")
	// ErrProcessOrderWithWindowTx is returned when there is an error with the ProcessOrders transaction.
	ErrProcessOrderWithWindowTx = errs.Class("process order with window transaction")
	// ErrGetStoragenodeBandwidthInWindow is returned when there is an error getting all storage node bandwidth for a window.
	ErrGetStoragenodeBandwidthInWindow = errs.Class("get storagenode bandwidth in window")
	// ErrCreateStoragenodeBandwidth is returned when there is an error updating storage node bandwidth.
	ErrCreateStoragenodeBandwidth = errs.Class("create storagenode bandwidth")
)
View Source
var (
	// ErrVetting is the error class for the following test methods.
	ErrVetting = errs.Class("vetting error")
)
View Source
var (
	// Error is the default satellitedb errs class.
	Error = errs.Class("satellitedb")
)

Functions

func New

func New(log *zap.Logger, databaseURL string, opts Options) (satellite.DB, error)

New creates instance of database supports postgres.

func SettledAmountsMatch added in v1.8.1

func SettledAmountsMatch(rows []*dbx.StoragenodeBandwidthRollup, orderActionAmounts map[int32]int64) bool

SettledAmountsMatch checks if database rows match the orders. If the settled amount for each action are not the same then false is returned.

Types

type ConsoleDB

type ConsoleDB struct {
	// contains filtered or unexported fields
}

ConsoleDB contains access to different satellite databases.

func (*ConsoleDB) APIKeys

func (db *ConsoleDB) APIKeys() console.APIKeys

APIKeys is a getter for APIKeys repository.

func (*ConsoleDB) ProjectMembers

func (db *ConsoleDB) ProjectMembers() console.ProjectMembers

ProjectMembers is a getter for ProjectMembers repository.

func (*ConsoleDB) Projects

func (db *ConsoleDB) Projects() console.Projects

Projects is a getter for Projects repository.

func (*ConsoleDB) RegistrationTokens

func (db *ConsoleDB) RegistrationTokens() console.RegistrationTokens

RegistrationTokens is a getter for RegistrationTokens repository.

func (*ConsoleDB) ResetPasswordTokens added in v0.12.0

func (db *ConsoleDB) ResetPasswordTokens() console.ResetPasswordTokens

ResetPasswordTokens is a getter for ResetPasswordTokens repository.

func (*ConsoleDB) UserCredits added in v0.14.0

func (db *ConsoleDB) UserCredits() console.UserCredits

UserCredits is a getter for console.UserCredits repository.

func (*ConsoleDB) Users

func (db *ConsoleDB) Users() console.Users

Users is getter a for Users repository.

func (*ConsoleDB) WithTx added in v0.29.1

func (db *ConsoleDB) WithTx(ctx context.Context, fn func(context.Context, console.DBTx) error) error

WithTx is a method for executing and retrying transaction.

type DBTx

type DBTx struct {
	*ConsoleDB
}

DBTx extends Database with transaction scope.

func (*DBTx) Commit

func (db *DBTx) Commit() error

Commit is a method for committing and closing transaction.

func (*DBTx) Rollback

func (db *DBTx) Rollback() error

Rollback is a method for rollback and closing transaction.

type Options added in v0.29.4

type Options struct {
	APIKeysLRUOptions    cache.Options
	RevocationLRUOptions cache.Options

	// How many records to read in a single transaction when asked for all of the
	// billable bandwidth from the reported serials table.
	ReportedRollupsReadBatchSize int
}

Options includes options for how a satelliteDB runs.

type ProjectAccounting added in v0.12.0

type ProjectAccounting struct {
	// contains filtered or unexported fields
}

ProjectAccounting implements the accounting/db ProjectAccounting interface.

func (*ProjectAccounting) CreateStorageTally added in v0.12.0

func (db *ProjectAccounting) CreateStorageTally(ctx context.Context, tally accounting.BucketStorageTally) (err error)

CreateStorageTally creates a record in the bucket_storage_tallies accounting table.

func (*ProjectAccounting) DeleteProjectAllocatedBandwidthBefore added in v1.9.1

func (db *ProjectAccounting) DeleteProjectAllocatedBandwidthBefore(ctx context.Context, before time.Time) (err error)

DeleteProjectAllocatedBandwidthBefore deletes project bandwidth rollups before the given time.

func (*ProjectAccounting) GetAllocatedBandwidthTotal added in v0.12.0

func (db *ProjectAccounting) GetAllocatedBandwidthTotal(ctx context.Context, projectID uuid.UUID, from time.Time) (_ int64, err error)

GetAllocatedBandwidthTotal returns the sum of GET bandwidth usage allocated for a projectID for a time frame.

func (*ProjectAccounting) GetBucketTotals added in v0.26.0

func (db *ProjectAccounting) GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor accounting.BucketUsageCursor, since, before time.Time) (_ *accounting.BucketUsagePage, err error)

GetBucketTotals retrieves bucket usage totals for period of time.

func (*ProjectAccounting) GetBucketUsageRollups added in v0.26.0

func (db *ProjectAccounting) GetBucketUsageRollups(ctx context.Context, projectID uuid.UUID, since, before time.Time) (_ []accounting.BucketUsageRollup, err error)

GetBucketUsageRollups retrieves summed usage rollups for every bucket of particular project for a given period.

func (*ProjectAccounting) GetProjectAllocatedBandwidth added in v1.4.3

func (db *ProjectAccounting) GetProjectAllocatedBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month) (_ int64, err error)

GetProjectAllocatedBandwidth returns allocated bandwidth for the specified year and month.

func (*ProjectAccounting) GetProjectBandwidthLimit added in v0.27.0

func (db *ProjectAccounting) GetProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)

GetProjectBandwidthLimit returns project bandwidth usage limit.

func (*ProjectAccounting) GetProjectLimits added in v1.14.1

func (db *ProjectAccounting) GetProjectLimits(ctx context.Context, projectID uuid.UUID) (_ accounting.ProjectLimits, err error)

GetProjectLimits returns current project limit for both storage and bandwidth.

func (*ProjectAccounting) GetProjectStorageLimit added in v0.27.0

func (db *ProjectAccounting) GetProjectStorageLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)

GetProjectStorageLimit returns project storage usage limit.

func (*ProjectAccounting) GetProjectTotal added in v0.26.0

func (db *ProjectAccounting) GetProjectTotal(ctx context.Context, projectID uuid.UUID, since, before time.Time) (usage *accounting.ProjectUsage, err error)

GetProjectTotal retrieves project usage for a given period.

func (*ProjectAccounting) GetStorageTotals added in v0.12.0

func (db *ProjectAccounting) GetStorageTotals(ctx context.Context, projectID uuid.UUID) (inline int64, remote int64, err error)

GetStorageTotals returns the current inline and remote storage usage for a projectID.

func (*ProjectAccounting) GetTallies added in v0.21.0

func (db *ProjectAccounting) GetTallies(ctx context.Context) (tallies []accounting.BucketTally, err error)

GetTallies saves the latest bucket info.

func (*ProjectAccounting) SaveTallies added in v0.12.0

func (db *ProjectAccounting) SaveTallies(ctx context.Context, intervalStart time.Time, bucketTallies map[metabase.BucketLocation]*accounting.BucketTally) (err error)

SaveTallies saves the latest bucket info.

func (*ProjectAccounting) UpdateProjectBandwidthLimit added in v1.4.3

func (db *ProjectAccounting) UpdateProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) (err error)

UpdateProjectBandwidthLimit updates project bandwidth limit.

func (*ProjectAccounting) UpdateProjectUsageLimit added in v0.27.0

func (db *ProjectAccounting) UpdateProjectUsageLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) (err error)

UpdateProjectUsageLimit updates project usage limit.

type StoragenodeAccounting added in v0.12.0

type StoragenodeAccounting struct {
	// contains filtered or unexported fields
}

StoragenodeAccounting implements the accounting/db StoragenodeAccounting interface.

func (*StoragenodeAccounting) DeleteTalliesBefore added in v0.12.0

func (db *StoragenodeAccounting) DeleteTalliesBefore(ctx context.Context, latestRollup time.Time) (err error)

DeleteTalliesBefore deletes all raw tallies prior to some time.

func (*StoragenodeAccounting) GetBandwidthSince added in v0.12.0

func (db *StoragenodeAccounting) GetBandwidthSince(ctx context.Context, latestRollup time.Time) (_ []*accounting.StoragenodeBandwidthRollup, err error)

GetBandwidthSince retrieves all storagenode_bandwidth_rollup entires since latestRollup.

func (*StoragenodeAccounting) GetTallies added in v0.12.0

GetTallies retrieves all raw tallies.

func (*StoragenodeAccounting) GetTalliesSince added in v0.12.0

func (db *StoragenodeAccounting) GetTalliesSince(ctx context.Context, latestRollup time.Time) (_ []*accounting.StoragenodeStorageTally, err error)

GetTalliesSince retrieves all raw tallies since latestRollup.

func (*StoragenodeAccounting) LastTimestamp added in v0.12.0

func (db *StoragenodeAccounting) LastTimestamp(ctx context.Context, timestampType string) (_ time.Time, err error)

LastTimestamp records the greatest last tallied time.

func (*StoragenodeAccounting) QueryPaymentInfo added in v0.12.0

func (db *StoragenodeAccounting) QueryPaymentInfo(ctx context.Context, start time.Time, end time.Time) (_ []*accounting.CSVRow, err error)

QueryPaymentInfo queries Overlay, Accounting Rollup on nodeID.

func (*StoragenodeAccounting) QueryStorageNodePeriodUsage added in v1.1.1

func (db *StoragenodeAccounting) QueryStorageNodePeriodUsage(ctx context.Context, period compensation.Period) (_ []accounting.StorageNodePeriodUsage, err error)

QueryStorageNodePeriodUsage returns usage invoices for nodes for a compensation period.

func (*StoragenodeAccounting) QueryStorageNodeUsage added in v0.18.0

func (db *StoragenodeAccounting) QueryStorageNodeUsage(ctx context.Context, nodeID storj.NodeID, start time.Time, end time.Time) (_ []accounting.StorageNodeUsage, err error)

QueryStorageNodeUsage returns slice of StorageNodeUsage for given period.

func (*StoragenodeAccounting) SaveRollup added in v0.12.0

func (db *StoragenodeAccounting) SaveRollup(ctx context.Context, latestRollup time.Time, stats accounting.RollupStats) (err error)

SaveRollup records raw tallies of at rest data to the database.

func (*StoragenodeAccounting) SaveTallies added in v0.12.0

func (db *StoragenodeAccounting) SaveTallies(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]float64) (err error)

SaveTallies records raw tallies of at rest data to the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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