sqlstorage

package
v1.4.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

File is part of the build only if cgo is enabled. Otherwise, the compilation will complains about missing type sqlite3,Error It is due to the fact than sqlite lib use import "C" statement. The presence of these statement during the build exclude the file if CGO is disabled.

Index

Constants

View Source
const SystemSchema = "_system"

Variables

View Source
var (
	SQLite     = Flavor(sqlbuilder.SQLite)
	PostgreSQL = Flavor(sqlbuilder.PostgreSQL)
)
View Source
var MigrationsFs fs.FS

Functions

func DriverModule

func DriverModule(cfg ModuleConfig) fx.Option

func NewPostgresDB added in v1.3.2

func NewPostgresDB(db *sql.DB) *postgresDB

func NewSQLiteDB added in v1.3.2

func NewSQLiteDB(directory, dbName string) *sqliteDB

func OpenSQLDB added in v1.3.2

func OpenSQLDB(flavor Flavor, dataSourceName string) (*sql.DB, error)

func SQLDriverName

func SQLDriverName(f Flavor) string

func UpdateSQLDriverMapping

func UpdateSQLDriverMapping(flavor Flavor, name string)

Types

type DB added in v1.3.2

type DB interface {
	Initialize(ctx context.Context) error
	Schema(ctx context.Context, name string) (Schema, error)
	Close(ctx context.Context) error
}

type Driver added in v1.3.2

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

func NewDriver added in v1.3.2

func NewDriver(name string, db DB) *Driver

func (*Driver) Close added in v1.3.2

func (d *Driver) Close(ctx context.Context) error

func (*Driver) DeleteStore added in v1.3.2

func (s *Driver) DeleteStore(ctx context.Context, name string) error

func (*Driver) GetStore added in v1.3.2

func (s *Driver) GetStore(ctx context.Context, name string, create bool) (storage.Store, bool, error)

func (*Driver) Initialize added in v1.3.2

func (s *Driver) Initialize(ctx context.Context) error

func (*Driver) List added in v1.3.2

func (d *Driver) List(ctx context.Context) ([]string, error)

func (*Driver) Name added in v1.3.2

func (s *Driver) Name() string

func (*Driver) Register added in v1.3.2

func (d *Driver) Register(ctx context.Context, ledger string) (bool, error)

type Flavor

type Flavor sqlbuilder.Flavor

func FlavorFromString

func FlavorFromString(v string) Flavor

func (Flavor) AttributeKeyValue

func (f Flavor) AttributeKeyValue() attribute.KeyValue

func (Flavor) String

func (f Flavor) String() string

type ModuleConfig

type ModuleConfig struct {
	StorageDriver  string
	SQLiteConfig   *SQLiteConfig
	PostgresConfig *PostgresConfig
}

type PGSchema added in v1.3.2

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

func (*PGSchema) Close added in v1.3.2

func (s *PGSchema) Close(ctx context.Context) error

func (*PGSchema) Delete added in v1.3.2

func (s *PGSchema) Delete(ctx context.Context) error

func (*PGSchema) ExecContext added in v1.3.2

func (s *PGSchema) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*PGSchema) Flavor added in v1.3.2

func (s *PGSchema) Flavor() sqlbuilder.Flavor

func (*PGSchema) Initialize added in v1.3.2

func (s *PGSchema) Initialize(ctx context.Context) error

func (*PGSchema) Name added in v1.3.2

func (s *PGSchema) Name() string

func (*PGSchema) QueryContext added in v1.3.2

func (s *PGSchema) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*PGSchema) QueryRowContext added in v1.3.2

func (s *PGSchema) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (*PGSchema) Table added in v1.3.2

func (s *PGSchema) Table(name string) string

type PostgresConfig

type PostgresConfig struct {
	ConnString string
}

type SQLiteConfig

type SQLiteConfig struct {
	Dir    string
	DBName string
}

type SQLiteSchema added in v1.3.2

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

func (*SQLiteSchema) Close added in v1.3.2

func (s *SQLiteSchema) Close(ctx context.Context) error

func (SQLiteSchema) Delete added in v1.3.2

func (s SQLiteSchema) Delete(ctx context.Context) error

func (*SQLiteSchema) ExecContext added in v1.3.2

func (s *SQLiteSchema) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (SQLiteSchema) Flavor added in v1.3.2

func (s SQLiteSchema) Flavor() sqlbuilder.Flavor

func (*SQLiteSchema) Initialize added in v1.3.2

func (s *SQLiteSchema) Initialize(ctx context.Context) error

func (*SQLiteSchema) Name added in v1.3.2

func (s *SQLiteSchema) Name() string

func (*SQLiteSchema) QueryContext added in v1.3.2

func (s *SQLiteSchema) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*SQLiteSchema) QueryRowContext added in v1.3.2

func (s *SQLiteSchema) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (*SQLiteSchema) Table added in v1.3.2

func (s *SQLiteSchema) Table(name string) string

type Schema added in v1.3.2

type Schema interface {
	Initialize(ctx context.Context) error
	Table(name string) string
	Close(ctx context.Context) error
	BeginTx(ctx context.Context, s *sql.TxOptions) (*sql.Tx, error)
	Flavor() sqlbuilder.Flavor
	Name() string
	Delete(ctx context.Context) error
	// contains filtered or unexported methods
}

type Store

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

func NewStore

func NewStore(schema Schema, onClose func(ctx context.Context) error) (*Store, error)

func (*Store) AggregateVolumes

func (s *Store) AggregateVolumes(ctx context.Context, address string) (core.Volumes, error)

func (*Store) AppendLog added in v1.3.2

func (s *Store) AppendLog(ctx context.Context, logs ...core.Log) (map[int]error, error)

func (*Store) Close

func (s *Store) Close(ctx context.Context) error

func (*Store) CountAccounts

func (s *Store) CountAccounts(ctx context.Context) (int64, error)

func (*Store) CountTransactions

func (s *Store) CountTransactions(ctx context.Context) (int64, error)

func (*Store) FindAccounts

func (s *Store) FindAccounts(ctx context.Context, q query.Query) (sharedapi.Cursor, error)

func (*Store) FindTransactions

func (s *Store) FindTransactions(ctx context.Context, q query.Query) (sharedapi.Cursor, error)

func (*Store) GetAccount added in v1.3.2

func (s *Store) GetAccount(ctx context.Context, addr string) (core.Account, error)

func (*Store) GetTransaction

func (s *Store) GetTransaction(ctx context.Context, txId uint64) (tx core.Transaction, err error)

func (*Store) Initialize

func (s *Store) Initialize(ctx context.Context) (bool, error)

func (*Store) LastLog added in v1.3.2

func (s *Store) LastLog(ctx context.Context) (*core.Log, error)

func (*Store) LoadMapping

func (s *Store) LoadMapping(ctx context.Context) (*core.Mapping, error)

func (*Store) Logs added in v1.3.2

func (s *Store) Logs(ctx context.Context) ([]core.Log, error)

func (*Store) Name

func (s *Store) Name() string

func (*Store) SaveMapping

func (s *Store) SaveMapping(ctx context.Context, mapping core.Mapping) error

func (*Store) Schema added in v1.3.2

func (s *Store) Schema() Schema

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳