storagenodedb

package
v1.118.2-rc Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const APIKeysDBName = "secret"

APIKeysDBName represents the database name.

View Source
const BandwidthDBName = "bandwidth"

BandwidthDBName represents the database name.

View Source
const DeprecatedInfoDBName = "info"

DeprecatedInfoDBName represents the database name.

View Source
const GCFilewalkerProgressDBName = "garbage_collection_filewalker_progress"

GCFilewalkerProgressDBName represents the database name.

View Source
const HeldAmountDBName = "heldamount"

HeldAmountDBName represents the database name.

View Source
const NotificationsDBName = "notifications"

NotificationsDBName represents the database name.

View Source
const OrdersDBName = "orders"

OrdersDBName represents the database name.

View Source
const PieceExpirationDBName = "piece_expiration"

PieceExpirationDBName represents the database filename.

View Source
const PieceInfoDBName = "pieceinfo"

PieceInfoDBName represents the database name.

View Source
const PieceSpaceUsedDBName = "piece_spaced_used"

PieceSpaceUsedDBName represents the database name.

View Source
const PricingDBName = "pricing"

PricingDBName represents the database name.

View Source
const ReputationDBName = "reputation"

ReputationDBName represents the database name.

View Source
const SatellitesDBName = "satellites"

SatellitesDBName represents the database name.

View Source
const StorageUsageDBName = "storage_usage"

StorageUsageDBName represents the database name.

View Source
const UsedSerialsDBName = "used_serial"

UsedSerialsDBName represents the database name.

View Source
const UsedSpacePerPrefixDBName = "used_space_per_prefix"

UsedSpacePerPrefixDBName represents the database name.

View Source
const VersionTable = "versions"

VersionTable is the table that stores the version info in each db.

Variables

View Source
var (

	// ErrDatabase represents errors from the databases.
	ErrDatabase = errs.Class("database")
	// ErrNoRows represents database error if rows weren't affected.
	ErrNoRows = errs.New("no rows affected")
	// ErrPreflight represents an error during the preflight check.
	ErrPreflight = errs.Class("preflight")
)
View Source
var (
	// ErrPieceExpiration represents errors from the piece expiration database.
	ErrPieceExpiration = errs.Class("pieceexpirationdb")

	// MaxPieceExpirationBufferSize is the maximum number of pieces that can be stored in the buffer before
	// they are written to the database.
	MaxPieceExpirationBufferSize = 1000 // TODO: make this configurable and set it at the top level.
)
View Source
var ErrAPIKeysDB = errs.Class("apikeysdb")

ErrAPIKeysDB represents errors from the api keys database.

View Source
var ErrBandwidth = errs.Class("bandwidthdb")

ErrBandwidth represents errors from the bandwidthdb database.

View Source
var (
	// ErrGCProgress represents errors from the filewalker database.
	ErrGCProgress = errs.Class("gc_filewalker_progress_db")
)
View Source
var ErrNotificationsDB = errs.Class("notificationsdb")

ErrNotificationsDB represents errors from the notifications database.

View Source
var ErrOrders = errs.Class("ordersdb")

ErrOrders represents errors from the ordersdb database.

View Source
var ErrPayout = errs.Class("payouts")

ErrPayout represents errors from the payouts database.

View Source
var ErrPieceInfo = errs.Class("v0pieceinfodb")

ErrPieceInfo represents errors from the piece info database.

View Source
var ErrPieceSpaceUsed = errs.Class("piece space used")

ErrPieceSpaceUsed represents errors from the piece spaced used database.

View Source
var ErrPricing = errs.Class("pricing")

ErrPricing represents errors from the pricing database.

View Source
var ErrReputation = errs.Class("reputation")

ErrReputation represents errors from the reputation database.

View Source
var ErrSatellitesDB = errs.Class("satellitesdb")

ErrSatellitesDB represents errors from the satellites database.

View Source
var ErrUsedSpacePerPrefix = errs.Class("used_space_per_prefix_db")

ErrUsedSpacePerPrefix represents errors from the used space per prefix database.

Functions

func Schema added in v0.30.4

func Schema() map[string]*dbschema.Schema

Types

type BandwidthDB added in v1.117.3

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

BandwidthDB is a database for tracking bandwidth usage.

func (*BandwidthDB) Add added in v1.117.3

func (db *BandwidthDB) Add(ctx context.Context, satelliteID storj.NodeID, action pb.PieceAction, amount int64, created time.Time) (err error)

Add adds bandwidth usage to the table.

func (*BandwidthDB) AddBatch added in v1.117.3

func (db *BandwidthDB) AddBatch(ctx context.Context, usages map[bandwidth.CacheKey]*bandwidth.Usage) (err error)

AddBatch adds bandwidth usage to the table.

func (*BandwidthDB) Configure added in v1.117.3

func (db *BandwidthDB) Configure(newDB tagsql.DB)

Configure sets the underlining SQLDB connection.

func (*BandwidthDB) EgressSummary added in v1.117.3

func (db *BandwidthDB) EgressSummary(ctx context.Context, from, to time.Time) (_ *bandwidth.Usage, err error)

EgressSummary returns summary of egress usages for all satellites.

func (*BandwidthDB) GetDB added in v1.117.3

func (db *BandwidthDB) GetDB() tagsql.DB

GetDB returns underlying implementation of dbContainerImpl.

func (*BandwidthDB) GetDailyRollups added in v1.117.3

func (db *BandwidthDB) GetDailyRollups(ctx context.Context, from, to time.Time) (_ []bandwidth.UsageRollup, err error)

GetDailyRollups returns slice of daily bandwidth usage rollups for provided time range, sorted in ascending order.

func (*BandwidthDB) GetDailySatelliteRollups added in v1.117.3

func (db *BandwidthDB) GetDailySatelliteRollups(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (_ []bandwidth.UsageRollup, err error)

GetDailySatelliteRollups returns slice of daily bandwidth usage for provided time range, sorted in ascending order for a particular satellite.

func (*BandwidthDB) IngressSummary added in v1.117.3

func (db *BandwidthDB) IngressSummary(ctx context.Context, from, to time.Time) (_ *bandwidth.Usage, err error)

IngressSummary returns summary of ingress usages for all satellites.

func (*BandwidthDB) MonthSummary added in v1.117.3

func (db *BandwidthDB) MonthSummary(ctx context.Context, now time.Time) (_ int64, err error)

MonthSummary returns summary of the current months bandwidth usages.

func (*BandwidthDB) SatelliteEgressSummary added in v1.117.3

func (db *BandwidthDB) SatelliteEgressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (_ *bandwidth.Usage, err error)

SatelliteEgressSummary returns summary of egress usage for a particular satellite.

func (*BandwidthDB) SatelliteIngressSummary added in v1.117.3

func (db *BandwidthDB) SatelliteIngressSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (_ *bandwidth.Usage, err error)

SatelliteIngressSummary returns summary of ingress usage for a particular satellite.

func (*BandwidthDB) SatelliteSummary added in v1.117.3

func (db *BandwidthDB) SatelliteSummary(ctx context.Context, satelliteID storj.NodeID, from, to time.Time) (_ *bandwidth.Usage, err error)

SatelliteSummary returns summary of bandwidth usages for a particular satellite.

func (*BandwidthDB) Summary added in v1.117.3

func (db *BandwidthDB) Summary(ctx context.Context, from, to time.Time) (_ *bandwidth.Usage, err error)

Summary returns summary of bandwidth usages for all satellites.

func (*BandwidthDB) SummaryBySatellite added in v1.117.3

func (db *BandwidthDB) SummaryBySatellite(ctx context.Context, from, to time.Time) (_ map[storj.NodeID]*bandwidth.Usage, err error)

SummaryBySatellite returns summary of bandwidth usage grouping by satellite.

type Config

type Config struct {
	// TODO: figure out better names
	Storage   string
	Cache     string
	Info      string
	Info2     string
	Driver    string // if unset, uses sqlite3
	Pieces    string
	Filestore filestore.Config

	TestingDisableWAL bool
}

Config configures storage node database.

func (Config) LazyFilewalkerConfig added in v1.79.1

func (config Config) LazyFilewalkerConfig() lazyfilewalker.Config

LazyFilewalkerConfig creates a lazyfilewalker.Config from storagenodedb.Config.

TODO: this is a temporary solution to avoid circular dependencies.

type DB

type DB struct {
	SQLDBs map[string]DBContainer
	// contains filtered or unexported fields
}

DB contains access to different database tables.

func OpenExisting added in v1.17.1

func OpenExisting(ctx context.Context, log *zap.Logger, config Config) (*DB, error)

OpenExisting opens an existing master database for storage node.

func OpenNew added in v1.17.1

func OpenNew(ctx context.Context, log *zap.Logger, config Config) (*DB, error)

OpenNew creates a new master database for storage node.

func (*DB) APIKeys added in v1.20.1

func (db *DB) APIKeys() apikeys.DB

APIKeys returns instance of the APIKeys database.

func (*DB) Bandwidth

func (db *DB) Bandwidth() bandwidth.DB

Bandwidth returns the instance of the Bandwidth database.

func (*DB) CheckVersion added in v1.14.1

func (db *DB) CheckVersion(ctx context.Context) error

CheckVersion that the version of the migration matches the state of the database.

func (*DB) Close

func (db *DB) Close() error

Close closes any resources.

func (*DB) Config added in v1.79.1

func (db *DB) Config() Config

Config returns the database configuration used to initialize the database.

func (*DB) DBDirectory added in v1.69.1

func (db *DB) DBDirectory() string

DBDirectory returns the database directory for testing purposes.

func (*DB) GCFilewalkerProgress added in v1.100.2

func (db *DB) GCFilewalkerProgress() pieces.GCFilewalkerProgressDB

GCFilewalkerProgress returns the instance of the GCFilewalkerProgress database.

func (*DB) MigrateToLatest added in v1.4.1

func (db *DB) MigrateToLatest(ctx context.Context) error

MigrateToLatest creates any necessary tables.

func (*DB) Migration added in v0.19.0

func (db *DB) Migration(ctx context.Context) *migrate.Migration

Migration returns table migrations.

func (*DB) Notifications added in v0.28.0

func (db *DB) Notifications() notifications.DB

Notifications returns the instance of the Notifications database.

func (*DB) Orders

func (db *DB) Orders() orders.DB

Orders returns the instance of the Orders database.

func (*DB) Payout added in v1.13.1

func (db *DB) Payout() payouts.DB

Payout returns instance of the SnoPayout database.

func (*DB) PieceExpirationDB added in v0.18.0

func (db *DB) PieceExpirationDB() pieces.PieceExpirationDB

PieceExpirationDB returns the instance of the PieceExpiration database.

func (*DB) PieceSpaceUsedDB added in v0.18.0

func (db *DB) PieceSpaceUsedDB() pieces.PieceSpaceUsedDB

PieceSpaceUsedDB returns the instance of the PieceSpacedUsed database.

func (*DB) Pieces

func (db *DB) Pieces() blobstore.Blobs

Pieces returns blob storage for pieces.

func (*DB) Preflight added in v0.30.4

func (db *DB) Preflight(ctx context.Context) (err error)

Preflight conducts a pre-flight check to ensure correct schemas and minimal read+write functionality of the database tables.

func (*DB) Pricing added in v1.3.2

func (db *DB) Pricing() pricing.DB

Pricing returns instance of the Pricing database.

func (*DB) RawDatabases added in v0.21.0

func (db *DB) RawDatabases() map[string]DBContainer

RawDatabases are required for testing purposes.

func (*DB) Reputation added in v0.18.0

func (db *DB) Reputation() reputation.DB

Reputation returns the instance of the Reputation database.

func (*DB) Satellites added in v0.22.0

func (db *DB) Satellites() satellites.DB

Satellites returns the instance of the Satellites database.

func (*DB) StorageUsage added in v0.18.0

func (db *DB) StorageUsage() storageusage.DB

StorageUsage returns the instance of the StorageUsage database.

func (*DB) UsedSpacePerPrefix added in v1.100.2

func (db *DB) UsedSpacePerPrefix() pieces.UsedSpacePerPrefixDB

UsedSpacePerPrefix returns the instance of the UsedSpacePerPrefix database.

func (*DB) V0PieceInfo added in v0.18.0

func (db *DB) V0PieceInfo() pieces.V0PieceInfoDB

V0PieceInfo returns the instance of the V0PieceInfoDB database.

type DBContainer added in v0.28.0

type DBContainer interface {
	Configure(sqlDB tagsql.DB)
	GetDB() tagsql.DB
}

DBContainer defines an interface to allow accessing and setting a SQLDB.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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