storagenodedb

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInfo = errs.Class("infodb")

ErrInfo is the default error class for InfoDB

Functions

This section is empty.

Types

type Config

type Config struct {
	// TODO: figure out better names
	Storage  string
	Info     string
	Info2    string
	Kademlia string

	Pieces string
}

Config configures storage node database

type DB

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

DB contains access to different database tables

func New

func New(log *zap.Logger, config Config) (*DB, error)

New creates a new master database for storage node

func NewTest added in v0.16.0

func NewTest(log *zap.Logger, storageDir string) (*DB, error)

NewTest creates new test database for storage node.

func (*DB) Bandwidth

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

Bandwidth returns table for storing bandwidth usage.

func (*DB) Close

func (db *DB) Close() error

Close closes any resources.

func (*DB) Console added in v0.14.0

func (db *DB) Console() console.DB

Console returns console.DB

func (*DB) CreateTables

func (db *DB) CreateTables() error

CreateTables creates any necessary tables.

func (*DB) Orders

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

Orders returns database for storing orders

func (*DB) PieceInfo

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

PieceInfo returns database for storing piece information

func (*DB) Pieces

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

Pieces returns blob storage for pieces

func (*DB) RoutingTable

func (db *DB) RoutingTable() (kdb, ndb, adb storage.KeyValueStore)

RoutingTable returns kademlia routing table

func (*DB) UsedSerials

func (db *DB) UsedSerials() piecestore.UsedSerials

UsedSerials returns used serials database.

func (*DB) Vouchers added in v0.13.0

func (db *DB) Vouchers() vouchers.DB

Vouchers returns database for storing vouchers

type InfoDB

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

InfoDB implements information database for piecestore.

func NewInfoTest added in v0.16.0

func NewInfoTest() (*InfoDB, error)

NewInfoTest creates a new inmemory InfoDB.

func (*InfoDB) Bandwidth

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

Bandwidth returns table for storing bandwidth usage.

func (*InfoDB) Begin

func (db *InfoDB) Begin() (*sql.Tx, error)

Begin begins transaction

func (*InfoDB) Close

func (db *InfoDB) Close() error

Close closes any resources.

func (*InfoDB) Console added in v0.14.0

func (db *InfoDB) Console() console.DB

Console returns console.DB

func (*InfoDB) CreateTables

func (db *InfoDB) CreateTables(log *zap.Logger) error

CreateTables creates any necessary tables.

func (*InfoDB) Migration

func (db *InfoDB) Migration() *migrate.Migration

Migration returns table migrations.

func (*InfoDB) Orders

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

Orders returns database for storing orders

func (*InfoDB) PieceInfo

func (db *InfoDB) PieceInfo() pieces.DB

PieceInfo returns database for storing piece information

func (*InfoDB) RawDB

func (db *InfoDB) RawDB() SQLDB

RawDB returns access to the raw database, only for migration tests.

func (*InfoDB) Rebind

func (db *InfoDB) Rebind(s string) string

Rebind rebind parameters

func (*InfoDB) Schema

func (db *InfoDB) Schema() string

Schema returns schema

func (*InfoDB) UsedSerials

func (db *InfoDB) UsedSerials() piecestore.UsedSerials

UsedSerials returns used serials database.

func (*InfoDB) Vouchers added in v0.13.0

func (db *InfoDB) Vouchers() vouchers.DB

Vouchers returns database for storing vouchers

type SQLDB added in v0.16.0

type SQLDB interface {
	Begin() (*sql.Tx, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
	Close() error
	Conn(ctx context.Context) (*sql.Conn, error)
	Driver() driver.Driver
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Ping() error
	PingContext(ctx context.Context) error
	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	SetConnMaxLifetime(d time.Duration)
	SetMaxIdleConns(n int)
	SetMaxOpenConns(n int)
}

SQLDB defines interface that matches *sql.DB this is such that we can use utccheck.DB for the backend

TODO: wrap the connector instead of *sql.DB

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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