sqlstorage

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 25 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 SQLiteMemoryConnString = "file::memory:?cache=shared"

Variables

View Source
var (
	SQLite     = Flavor(sqlbuilder.SQLite)
	PostgreSQL = Flavor(sqlbuilder.PostgreSQL)
)

Functions

func DriverModule

func DriverModule(cfg ModuleConfig) fx.Option

func NewCachedDBDriver

func NewCachedDBDriver(logger logging.Logger, name string, flavor Flavor, where string) *cachedDBDriver

func NewInMemorySQLiteDriver

func NewInMemorySQLiteDriver(logger logging.Logger) *cachedDBDriver

func NewOpenCloseDBDriver

func NewOpenCloseDBDriver(logger logging.Logger, name string, flavor Flavor, connString ConnStringResolver) *openCloseDBDriver

func SQLDriverName

func SQLDriverName(f Flavor) string

func SQLiteFileConnString

func SQLiteFileConnString(path string) string

func TestingModule

func TestingModule() fx.Option

func UpdateSQLDriverMapping

func UpdateSQLDriverMapping(flavor Flavor, name string)

Types

type ConnStringResolver

type ConnStringResolver func(name string) string

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 PostgresConfig

type PostgresConfig struct {
	ConnString string
}

type SQLiteConfig

type SQLiteConfig struct {
	Dir    string
	DBName string
}

type Store

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

func NewStore

func NewStore(name string, flavor sqlbuilder.Flavor, db *sql.DB, logger logging.Logger, onClose func(ctx context.Context) error) (*Store, error)

func (*Store) AggregateBalances

func (s *Store) AggregateBalances(ctx context.Context, address string) (map[string]int64, error)

func (*Store) AggregateVolumes

func (s *Store) AggregateVolumes(ctx context.Context, address string) (map[string]map[string]int64, 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) CountMeta

func (s *Store) CountMeta(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) (query.Cursor, error)

func (*Store) FindTransactions

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

func (*Store) GetMeta

func (s *Store) GetMeta(ctx context.Context, ty string, id string) (core.Metadata, error)

func (*Store) GetTransaction

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

func (*Store) Initialize

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

func (*Store) LastMetaID

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

func (*Store) LastTransaction

func (s *Store) LastTransaction(ctx context.Context) (*core.Transaction, error)

func (*Store) LoadMapping

func (s *Store) LoadMapping(ctx context.Context) (*core.Mapping, 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) SaveMeta

func (s *Store) SaveMeta(ctx context.Context, id int64, timestamp, targetType, targetID, key, value string) error

func (*Store) SaveTransactions

func (s *Store) SaveTransactions(ctx context.Context, ts []core.Transaction) (map[int]error, error)

Jump to

Keyboard shortcuts

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