facade

package
v3.15.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbFacade

type DbFacade struct {
	SqlDb      *sql.DB
	SqlDbCtrl  *commonDb.DbController
	GormDb     *gorm.DB
	SqlxDb     *sqlx.DB
	SqlxDbCtrl *commonSqlx.DbController
	// contains filtered or unexported fields
}

Gives facade interface supporting multiple object of db

This facade supports:

gorm - github.com/jinzhu/gorm
sqlx - github.com/fwtpe/owl-backend/common/db/sqlx
database/sql.DB
dbCtrl

Release resources

In order to release resources in solid way, this facade provides "SetReleaseCallback(func())" to register callback function which gets called before this object releases the connections of database.

func (*DbFacade) GetDbConfig

func (facade *DbFacade) GetDbConfig() *commonDb.DbConfig

Gets the configuration of database.

Warning: the information of password is revealed

func (*DbFacade) NewDbCtrl

func (facade *DbFacade) NewDbCtrl() *commonDb.DbController

Generates a new controller of sql.DB

func (*DbFacade) NewSqlxDbCtrl

func (facade *DbFacade) NewSqlxDbCtrl() *commonSqlx.DbController

Generates a new controller of sqlx.DB

func (*DbFacade) Open

func (facade *DbFacade) Open(dbConfig *commonDb.DbConfig) (err error)

Open this facade with ping()

func (*DbFacade) Release

func (facade *DbFacade) Release()

Close the database, release the resources

func (*DbFacade) SetReleaseCallback

func (facade *DbFacade) SetReleaseCallback(callback func())

Sets the callback used before releasing connections

Jump to

Keyboard shortcuts

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