nrdatasource

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDatabase         = errors.New("no database found with the specified name")
	ErrDriverNotSupported = errors.New("database driver not supported")
)

Global errors

Functions

This section is empty.

Types

type DBAccess

type DBAccess interface {
	New(config DBConfig) (*sqlx.DB, error)
	Get() (*sqlx.DB, error)
	Close() error
	CanLock() bool
	RandomFuncName() string
}

DBAccess is the common interface for data access definitions

type DBConfig

type DBConfig struct {
	DBName             string
	Driver             string
	Address            string
	Username           string
	Password           string
	MaxOpenConnections int
	MaxIdleConnections int
	ConnectionLifetime time.Duration
}

DBConfig holds the configuration required to initialize a data source

type Generic

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

Generic is the generic data access implementation for `DBAccess` interface. Drivers currently supported: - mysql

func (*Generic) CanLock

func (g *Generic) CanLock() (lock bool)

CanLock returns true if the current driver supportes locking

func (*Generic) Close

func (g *Generic) Close() (err error)

Close should be called when the server ends the execution, so connection are gracefully released

func (*Generic) Get

func (g *Generic) Get() (db *sqlx.DB, err error)

Get returns the DB instance

func (*Generic) New

func (g *Generic) New(config DBConfig) (db *sqlx.DB, err error)

New configures the datasources

func (*Generic) RandomFuncName

func (g *Generic) RandomFuncName() (fName string)

RandomFuncName returns the driver's RANDOM name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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