db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(engine Engine, options DatabaseConnectionOpts) (*goqu.Database, error)

New initiates and returns a goqu database

func NewMySQLHandler

func NewMySQLHandler(options DatabaseConnectionOpts) (*sql.DB, error)

NewMySQLHandler instantiates a MySQLHandler struct an return its pointer

func NewPostgresHandler

func NewPostgresHandler(options DatabaseConnectionOpts) (*sql.DB, error)

NewPostgresHandler instantiates a PostgresHandler struct an return its pointer

Types

type DatabaseChecker

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

DatabaseChecker simple database checker for application

func NewChecker

func NewChecker(db *goqu.Database) *DatabaseChecker

NewChecker constructor

func (*DatabaseChecker) Diagnose

Diagnose start diagnose check http://confluence.alaudatech.com/pages/viewpage.action?pageId=14123161

type DatabaseConnectionOpts

type DatabaseConnectionOpts struct {
	Host               string
	Database           string
	User               string
	Password           string
	Port               string
	Timeout            int
	MaxConnections     int
	MaxIdleConnections int
	ConnMaxLifetime    int
	Params             map[string]string
}

DatabaseConnectionOpts common connection options

func NewDatabaseConnectionOpts

func NewDatabaseConnectionOpts(host, database, user, password, port string, timeout, maxConn, maxIdleConn, connMaxLifetime int) *DatabaseConnectionOpts

NewDatabaseConnectionOpts constructor function for DatabaseConnectionOpts

func (*DatabaseConnectionOpts) GetConnString

func (opts *DatabaseConnectionOpts) GetConnString() string

GetConnString returns a standard connection string

func (*DatabaseConnectionOpts) GetParams

func (opts *DatabaseConnectionOpts) GetParams() string

GetParams returns all the parameters with their values to be used in a connection string

type Engine

type Engine string

Engine database engine

const (
	// MySQL mysql database
	MySQL Engine = "mysql"
	// Postgres postgres database
	Postgres Engine = "postgres"
)

func (Engine) String

func (en Engine) String() string

type MySQLConnectionOpts

type MySQLConnectionOpts struct {
	DatabaseConnectionOpts
	Protocol string
}

MySQLConnectionOpts connection options for MySQL

func NewMySQLConnOptions

func NewMySQLConnOptions(
	dbConnOpts DatabaseConnectionOpts,
) *MySQLConnectionOpts

NewMySQLConnOptions constructor function for mysql specific connection options

func (*MySQLConnectionOpts) GetConnString

func (opts *MySQLConnectionOpts) GetConnString() string

GetConnString returns a connection string used to connect to a mysql database

type PostgresConnOptions

type PostgresConnOptions struct {
	DatabaseConnectionOpts
	SSLEnabled bool
}

PostgresConnOptions give optional configuration options for db connecton

func NewPostgresConnOptions

func NewPostgresConnOptions(
	dbConnectionOpts DatabaseConnectionOpts,
) *PostgresConnOptions

NewPostgresConnOptions constructor function for postgres specific connection options

func (*PostgresConnOptions) GetConnString

func (opts *PostgresConnOptions) GetConnString() string

GetConnString returns connection string postgres database

Jump to

Keyboard shortcuts

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