database

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultCoreDatabase const string for name of core database (sqlite filename)
	DefaultCoreDatabase = "qst.db"

	// DefaultCoinbaseDatabase const string for name of coinbase database (sqlite filename)
	DefaultCoinbaseDatabase = "qst_coinbase.db"

	// DefaultTDAmeritradeDatabase const string for name of td-ameritrade database (sqlite filename)
	DefaultTDAmeritradeDatabase = "qst_tdameritrade.db"

	// DefaultHost the default host to use to connect to the database
	DefaultHost = "127.0.0.1"

	// DefaultPort the default port to use to connect to the database
	DefaultPort = 3306

	// DefaultUsername the default username to use when first creating the database
	DefaultUsername = "qst"

	// DefaultPassword the default password to use when first creating the database
	DefaultPassword = "qu4n75t0pt3rm1nal1s4w3s0m3!"

	// DefaultSSLMode default ssl mode is off
	DefaultSSLMode = "false"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CoreConfig         *repository.InstanceConfig
	CoinbaseConfig     *repository.InstanceConfig
	TDAmeritradeConfig *repository.InstanceConfig
}

Config holds information for all databases

func NewConfig

func NewConfig(configDir string) *Config

NewConfig Generate default settings for the Config struct

type Database

type Database struct {
	*Config
	*service.Service
	CoreDB         *repository.CoreDatabase
	CoinbaseDB     *repository.Instance
	TDAmeritradeDB *repository.Instance
}

func NewDatabase

func NewDatabase(config *Config) (*Database, error)

NewDatabase creates the database connections

func (*Database) CheckConnection added in v0.3.0

func (db *Database) CheckConnection() error

CheckConnection checks to make sure the database is connected

func (*Database) Run added in v0.3.0

func (db *Database) Run(wg *sync.WaitGroup)

Run is the main thread of the process, called as a goroutine.

func (*Database) Start

func (db *Database) Start(group *sync.WaitGroup) error

Start spawns all processes done by the service.

func (*Database) Stop

func (db *Database) Stop() error

Stop terminates all processes belonging to the service.

type IDatabase added in v0.3.0

type IDatabase interface {
	IsConnected() bool
	GetSQL() (*sql.DB, error)
	GetConfig() *repository.InstanceConfig
}

IDatabase allows for the passing of a database struct without giving the receiver access to all functionality

type ISQL added in v0.3.0

type ISQL interface {
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

ISQL allows for the passing of an SQL connection without giving the receiver access to all functionality

type Logger added in v0.3.0

type Logger struct{}

Logger implements io.Writer interface to redirect SQL debug output to logger

func (Logger) Write added in v0.3.0

func (l Logger) Write(p []byte) (n int, err error)

Write takes input and sends to logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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