db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package db defines interface for using RDBMS

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapters

func Adapters() []string

func Drivers

func Drivers() []string

func RegisterAdapterFactory

func RegisterAdapterFactory(name string, factory AdapterFactory)

Types

type Adapter

type Adapter interface {
	DriverName() string
	Defaults() AdapterDefaults
	FormatDSN(c config.DatabaseConfig) (string, error)
	CanCreateDatabase() bool
	Placeholders(count int) string
}

Adapter is high level wrapper around underlying drivers

func GetAdapter

func GetAdapter(name string) (Adapter, error)

TODO: future, adapter factory functions should allow passing config

type AdapterDefaults

type AdapterDefaults interface {
	DockerImage() string
	Port() int
	NativeShell() string
}

type AdapterFactory

type AdapterFactory func() Adapter

type Manager

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

func NewManager

func NewManager(config config.DatabaseManagerConfig) *Manager

func (*Manager) Close

func (mgr *Manager) Close() error

func (*Manager) Config

func (mgr *Manager) Config(name string) (config.DatabaseConfig, error)

func (*Manager) Default

func (mgr *Manager) Default() (*Wrapper, error)

func (*Manager) DefaultConfig

func (mgr *Manager) DefaultConfig() (config.DatabaseConfig, error)

func (*Manager) DefaultName

func (mgr *Manager) DefaultName() (string, error)

func (*Manager) GetLogger

func (mgr *Manager) GetLogger() *dlog.Logger

func (*Manager) LoggerIdentity

func (mgr *Manager) LoggerIdentity(justCallMe func() dlog.Identity) dlog.Identity

func (*Manager) PrintConfig

func (mgr *Manager) PrintConfig()

func (*Manager) RegisteredAdapters

func (mgr *Manager) RegisteredAdapters() []string

func (*Manager) RegisteredDrivers

func (mgr *Manager) RegisteredDrivers() []string

func (*Manager) SetLogger

func (mgr *Manager) SetLogger(logger *dlog.Logger)

func (*Manager) Wrapper

func (mgr *Manager) Wrapper(name string, useDatabase bool) (*Wrapper, error)

type Wrapper

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

func NewWrapper

func NewWrapper(a Adapter) *Wrapper

func (*Wrapper) Adapter

func (w *Wrapper) Adapter() Adapter

func (*Wrapper) Close

func (w *Wrapper) Close() error

func (*Wrapper) CreateDatabase

func (w *Wrapper) CreateDatabase(name string) error

func (*Wrapper) GetDB

func (w *Wrapper) GetDB() *sql.DB

TODO: add error in return value? now we just warn if its nil ...

func (*Wrapper) GetLogger

func (w *Wrapper) GetLogger() *dlog.Logger

func (*Wrapper) LoggerIdentity

func (w *Wrapper) LoggerIdentity(justCallMe func() dlog.Identity) dlog.Identity

func (*Wrapper) Ping

func (w *Wrapper) Ping(timeout time.Duration) (time.Duration, error)

func (*Wrapper) SetDB

func (w *Wrapper) SetDB(db *sql.DB)

func (*Wrapper) SetLogger

func (w *Wrapper) SetLogger(logger *dlog.Logger)

func (*Wrapper) Transaction

func (w *Wrapper) Transaction() (*sql.Tx, error)

Directories

Path Synopsis
adapters
mysql
Package mysql wraps github.com/go-sql-driver/mysql
Package mysql wraps github.com/go-sql-driver/mysql
postgres
Package postgres wraps github.com/jackc/pgx
Package postgres wraps github.com/jackc/pgx
sqlite
Package sqlite wraps github.com/mattn/go-sqlite3
Package sqlite wraps github.com/mattn/go-sqlite3
Package migration provides database schema migration
Package migration provides database schema migration

Jump to

Keyboard shortcuts

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