Documentation ¶
Index ¶
- Constants
- Variables
- func Open(ctx context.Context, log *zap.Logger, databaseURL string, opts Options) (rv satellite.DB, err error)
- func SettledAmountsMatch(rows []*dbx.StoragenodeBandwidthRollup, orderActionAmounts map[int32]int64) bool
- type ConsoleDB
- func (db *ConsoleDB) APIKeys() console.APIKeys
- func (db *ConsoleDB) AccountFreezeEvents() console.AccountFreezeEvents
- func (db *ConsoleDB) ProjectMembers() console.ProjectMembers
- func (db *ConsoleDB) Projects() console.Projects
- func (db *ConsoleDB) RegistrationTokens() console.RegistrationTokens
- func (db *ConsoleDB) ResetPasswordTokens() console.ResetPasswordTokens
- func (db *ConsoleDB) Users() console.Users
- func (db *ConsoleDB) WebappSessions() consoleauth.WebappSessions
- func (db *ConsoleDB) WithTx(ctx context.Context, fn func(context.Context, console.DBTx) error) error
- type DBTx
- type Options
- type ProjectAccounting
- func (db *ProjectAccounting) ArchiveRollupsBefore(ctx context.Context, before time.Time, batchSize int) (archivedCount int, err error)
- func (db *ProjectAccounting) CreateStorageTally(ctx context.Context, tally accounting.BucketStorageTally) (err error)
- func (db *ProjectAccounting) DeleteProjectBandwidthBefore(ctx context.Context, before time.Time) (err error)
- func (db *ProjectAccounting) GetArchivedRollupsSince(ctx context.Context, since time.Time) (bwRollups []orders.BucketBandwidthRollup, err error)
- func (db *ProjectAccounting) GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor accounting.BucketUsageCursor, ...) (_ *accounting.BucketUsagePage, err error)
- func (db *ProjectAccounting) GetBucketUsageRollups(ctx context.Context, projectID uuid.UUID, since, before time.Time) (_ []accounting.BucketUsageRollup, err error)
- func (db *ProjectAccounting) GetProjectBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int, ...) (_ int64, err error)
- func (db *ProjectAccounting) GetProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)
- func (db *ProjectAccounting) GetProjectDailyBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int) (allocated int64, settled, dead int64, err error)
- func (db *ProjectAccounting) GetProjectDailyUsageByDateRange(ctx context.Context, projectID uuid.UUID, from, to time.Time, ...) (_ *accounting.ProjectDailyUsage, err error)
- func (db *ProjectAccounting) GetProjectLimits(ctx context.Context, projectID uuid.UUID) (_ accounting.ProjectLimits, err error)
- func (db *ProjectAccounting) GetProjectObjectsSegments(ctx context.Context, projectID uuid.UUID) (objectsSegments *accounting.ProjectObjectsSegments, err error)
- func (db *ProjectAccounting) GetProjectSegmentLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)
- func (db *ProjectAccounting) GetProjectSettledBandwidthTotal(ctx context.Context, projectID uuid.UUID, from time.Time) (_ int64, err error)
- func (db *ProjectAccounting) GetProjectStorageLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)
- func (db *ProjectAccounting) GetProjectTotal(ctx context.Context, projectID uuid.UUID, since, before time.Time) (usage *accounting.ProjectUsage, err error)
- func (db *ProjectAccounting) GetRollupsSince(ctx context.Context, since time.Time) (bwRollups []orders.BucketBandwidthRollup, err error)
- func (db *ProjectAccounting) GetSingleBucketUsageRollup(ctx context.Context, projectID uuid.UUID, bucket string, ...) (_ *accounting.BucketUsageRollup, err error)
- func (db *ProjectAccounting) GetTallies(ctx context.Context) (tallies []accounting.BucketTally, err error)
- func (db *ProjectAccounting) SaveTallies(ctx context.Context, intervalStart time.Time, ...) (err error)
- func (db *ProjectAccounting) UpdateProjectBandwidthLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) (err error)
- func (db *ProjectAccounting) UpdateProjectSegmentLimit(ctx context.Context, projectID uuid.UUID, limit int64) (err error)
- func (db *ProjectAccounting) UpdateProjectUsageLimit(ctx context.Context, projectID uuid.UUID, limit memory.Size) (err error)
- type StoragenodeAccounting
- func (db *StoragenodeAccounting) ArchiveRollupsBefore(ctx context.Context, before time.Time, batchSize int) (nodeRollupsDeleted int, err error)
- func (db *StoragenodeAccounting) DeleteTalliesBefore(ctx context.Context, latestRollup time.Time, batchSize int) (err error)
- func (db *StoragenodeAccounting) GetArchivedRollupsSince(ctx context.Context, since time.Time) (bwRollups []accounting.StoragenodeBandwidthRollup, err error)
- func (db *StoragenodeAccounting) GetBandwidthSince(ctx context.Context, latestRollup time.Time, ...) (err error)
- func (db *StoragenodeAccounting) GetRollupsSince(ctx context.Context, since time.Time) (bwRollups []accounting.StoragenodeBandwidthRollup, err error)
- func (db *StoragenodeAccounting) GetTallies(ctx context.Context) (_ []*accounting.StoragenodeStorageTally, err error)
- func (db *StoragenodeAccounting) GetTalliesSince(ctx context.Context, latestRollup time.Time) (_ []*accounting.StoragenodeStorageTally, err error)
- func (db *StoragenodeAccounting) LastTimestamp(ctx context.Context, timestampType string) (_ time.Time, err error)
- func (db *StoragenodeAccounting) QueryPaymentInfo(ctx context.Context, start time.Time, end time.Time) (_ []*accounting.CSVRow, err error)
- func (db *StoragenodeAccounting) QueryStorageNodePeriodUsage(ctx context.Context, period compensation.Period) (_ []accounting.StorageNodePeriodUsage, err error)
- func (db *StoragenodeAccounting) QueryStorageNodeUsage(ctx context.Context, nodeID storj.NodeID, start time.Time, end time.Time) (_ []accounting.StorageNodeUsage, err error)
- func (db *StoragenodeAccounting) SaveRollup(ctx context.Context, latestRollup time.Time, stats accounting.RollupStats) (err error)
- func (db *StoragenodeAccounting) SaveTallies(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]float64) (err error)
Constants ¶
const RepairQueueSelectLimit = 1000
RepairQueueSelectLimit defines how many items can be selected at the same time.
const ( // VerifyRetryInterval defines a limit on how frequently we retry // verification audits. At least this long should elapse between // attempts. VerifyRetryInterval = 4 * time.Hour )
Variables ¶
var ( // ErrMigrate is for tracking migration errors. ErrMigrate = errs.Class("migrate") // ErrMigrateMinVersion is for migration min version errors. ErrMigrateMinVersion = errs.Class("migrate min version") )
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") )
var ( // ErrVetting is the error class for the following test methods. ErrVetting = errs.Class("vetting") )
var Error = errs.Class("satellitedb")
Error is the default satellitedb errs class.
Functions ¶
func Open ¶ added in v1.17.1
func Open(ctx context.Context, log *zap.Logger, databaseURL string, opts Options) (rv satellite.DB, err error)
Open creates instance of satellite.DB.
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) AccountFreezeEvents ¶ added in v1.70.1
func (db *ConsoleDB) AccountFreezeEvents() console.AccountFreezeEvents
AccountFreezeEvents is a getter for AccountFreezeEvents repository.
func (*ConsoleDB) ProjectMembers ¶
func (db *ConsoleDB) ProjectMembers() console.ProjectMembers
ProjectMembers is a getter for ProjectMembers 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) WebappSessions ¶ added in v1.56.1
func (db *ConsoleDB) WebappSessions() consoleauth.WebappSessions
WebappSessions is a getter for WebappSessions repository.
type DBTx ¶
type DBTx struct {
*ConsoleDB
}
DBTx extends Database with transaction scope.
type Options ¶ added in v0.29.4
type Options struct { ApplicationName string APIKeysLRUOptions lrucache.Options RevocationLRUOptions lrucache.Options // How many storage node rollups to save/read in one batch. SaveRollupBatchSize int ReadRollupBatchSize 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) ArchiveRollupsBefore ¶ added in v1.22.1
func (db *ProjectAccounting) ArchiveRollupsBefore(ctx context.Context, before time.Time, batchSize int) (archivedCount int, err error)
ArchiveRollupsBefore archives rollups older than a given time.
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) DeleteProjectBandwidthBefore ¶ added in v1.31.1
func (db *ProjectAccounting) DeleteProjectBandwidthBefore(ctx context.Context, before time.Time) (err error)
DeleteProjectBandwidthBefore deletes project bandwidth rollups before the given time.
func (*ProjectAccounting) GetArchivedRollupsSince ¶ added in v1.22.1
func (db *ProjectAccounting) GetArchivedRollupsSince(ctx context.Context, since time.Time) (bwRollups []orders.BucketBandwidthRollup, err error)
GetArchivedRollupsSince retrieves all archived rollup records since a given time.
func (*ProjectAccounting) GetBucketTotals ¶ added in v0.26.0
func (db *ProjectAccounting) GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor accounting.BucketUsageCursor, 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) GetProjectBandwidth ¶ added in v1.31.1
func (db *ProjectAccounting) GetProjectBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int, asOfSystemInterval time.Duration) (_ int64, err error)
GetProjectBandwidth returns the used bandwidth (settled or allocated) for the specified year, month and day.
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) GetProjectDailyBandwidth ¶ added in v1.31.1
func (db *ProjectAccounting) GetProjectDailyBandwidth(ctx context.Context, projectID uuid.UUID, year int, month time.Month, day int) (allocated int64, settled, dead int64, err error)
GetProjectDailyBandwidth returns project bandwidth (allocated and settled) for the specified day.
func (*ProjectAccounting) GetProjectDailyUsageByDateRange ¶ added in v1.49.3
func (db *ProjectAccounting) GetProjectDailyUsageByDateRange(ctx context.Context, projectID uuid.UUID, from, to time.Time, crdbInterval time.Duration) (_ *accounting.ProjectDailyUsage, err error)
GetProjectDailyUsageByDateRange returns project daily allocated, settled bandwidth and storage usage by specific date range.
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) GetProjectObjectsSegments ¶ added in v1.45.2
func (db *ProjectAccounting) GetProjectObjectsSegments(ctx context.Context, projectID uuid.UUID) (objectsSegments *accounting.ProjectObjectsSegments, err error)
GetProjectObjectsSegments retrieves project objects and segments.
func (*ProjectAccounting) GetProjectSegmentLimit ¶ added in v1.45.2
func (db *ProjectAccounting) GetProjectSegmentLimit(ctx context.Context, projectID uuid.UUID) (_ *int64, err error)
GetProjectSegmentLimit returns project segment limit.
func (*ProjectAccounting) GetProjectSettledBandwidthTotal ¶ added in v1.71.1
func (db *ProjectAccounting) GetProjectSettledBandwidthTotal(ctx context.Context, projectID uuid.UUID, from time.Time) (_ int64, err error)
GetProjectSettledBandwidthTotal returns the sum of GET bandwidth usage settled for a projectID in the past time frame.
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) GetRollupsSince ¶ added in v1.22.1
func (db *ProjectAccounting) GetRollupsSince(ctx context.Context, since time.Time) (bwRollups []orders.BucketBandwidthRollup, err error)
GetRollupsSince retrieves all archived rollup records since a given time.
func (*ProjectAccounting) GetSingleBucketUsageRollup ¶ added in v1.51.1
func (db *ProjectAccounting) GetSingleBucketUsageRollup(ctx context.Context, projectID uuid.UUID, bucket string, since, before time.Time) (_ *accounting.BucketUsageRollup, err error)
GetSingleBucketUsageRollup retrieves usage rollup for a single bucket of particular project for a given period.
func (*ProjectAccounting) GetTallies ¶ added in v0.21.0
func (db *ProjectAccounting) GetTallies(ctx context.Context) (tallies []accounting.BucketTally, err error)
GetTallies retrieves all tallies ordered by interval start (descending).
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) UpdateProjectSegmentLimit ¶ added in v1.45.2
func (db *ProjectAccounting) UpdateProjectSegmentLimit(ctx context.Context, projectID uuid.UUID, limit int64) (err error)
UpdateProjectSegmentLimit updates project segment 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) ArchiveRollupsBefore ¶ added in v1.22.1
func (db *StoragenodeAccounting) ArchiveRollupsBefore(ctx context.Context, before time.Time, batchSize int) (nodeRollupsDeleted int, err error)
ArchiveRollupsBefore archives rollups older than a given time.
func (*StoragenodeAccounting) DeleteTalliesBefore ¶ added in v0.12.0
func (db *StoragenodeAccounting) DeleteTalliesBefore(ctx context.Context, latestRollup time.Time, batchSize int) (err error)
DeleteTalliesBefore deletes all raw tallies prior to some time.
func (*StoragenodeAccounting) GetArchivedRollupsSince ¶ added in v1.22.1
func (db *StoragenodeAccounting) GetArchivedRollupsSince(ctx context.Context, since time.Time) (bwRollups []accounting.StoragenodeBandwidthRollup, err error)
GetArchivedRollupsSince retrieves all archived bandwidth rollup records since a given time.
func (*StoragenodeAccounting) GetBandwidthSince ¶ added in v0.12.0
func (db *StoragenodeAccounting) GetBandwidthSince(ctx context.Context, latestRollup time.Time, cb func(context.Context, *accounting.StoragenodeBandwidthRollup) error) (err error)
GetBandwidthSince retrieves all storagenode_bandwidth_rollup entires since latestRollup.
func (*StoragenodeAccounting) GetRollupsSince ¶ added in v1.22.1
func (db *StoragenodeAccounting) GetRollupsSince(ctx context.Context, since time.Time) (bwRollups []accounting.StoragenodeBandwidthRollup, err error)
GetRollupsSince retrieves all archived bandwidth rollup records since a given time.
func (*StoragenodeAccounting) GetTallies ¶ added in v0.12.0
func (db *StoragenodeAccounting) GetTallies(ctx context.Context) (_ []*accounting.StoragenodeStorageTally, err error)
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.
Source Files ¶
- accountfreezeevents.go
- apikeys.go
- attribution.go
- audithistory.go
- billingdb.go
- bucketsdb.go
- coinpaymentstxs.go
- compensation.go
- consoledb.go
- containment.go
- customers.go
- database.go
- gracefulexit.go
- invoiceprojectrecords.go
- migrate.go
- migratez.go
- nodeapiversion.go
- nodeevents.go
- nodeselection.go
- orders.go
- overlaycache.go
- payouts.go
- peeridentities.go
- projectaccounting.go
- projectmembers.go
- projects.go
- regtokens.go
- repairqueue.go
- reputations.go
- resetpasstokens.go
- reverifyqueue.go
- revocation.go
- storagenodeaccounting.go
- storjscanpayments.go
- storjscanwallets.go
- stripecoinpaymentsdb.go
- users.go
- verifyqueue.go
- webappsessions.go