dbrouter

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2018 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_TYPE_MONGO    = "mongo"
	DB_TYPE_MYSQL    = "mysql"
	DB_TYPE_POSTGRES = "postgres"
)

Variables

This section is empty.

Functions

func NewdbMongo

func NewdbMongo(dbtype, dbname string, cfg []byte) (*dbMongo, error)

func NewdbSql

func NewdbSql(dbtype, dbname string, cfg []byte) (*dbSql, error)

Types

type DB

type DB struct {
	*sqlx.DB
}

func NewDB

func NewDB(sqlxdb *sqlx.DB) *DB

func (*DB) ExecWrapper

func (db *DB) ExecWrapper(tables []interface{}, query string, args ...interface{}) (sql.Result, error)

func (*DB) GetWrapper

func (db *DB) GetWrapper(tables []interface{}, dest interface{}, query string, args ...interface{}) error

func (*DB) NamedExecWrapper

func (db *DB) NamedExecWrapper(tables []interface{}, query string, arg interface{}) (sql.Result, error)

func (*DB) NamedQueryWrapper

func (db *DB) NamedQueryWrapper(tables []interface{}, query string, arg interface{}) (*sqlx.Rows, error)

func (*DB) QueryRowxWrapper

func (db *DB) QueryRowxWrapper(tables []interface{}, query string, args ...interface{}) *sqlx.Row

func (*DB) QueryxWrapper

func (db *DB) QueryxWrapper(tables []interface{}, query string, args ...interface{}) (*sqlx.Rows, error)

func (*DB) SelectWrapper

func (db *DB) SelectWrapper(tables []interface{}, dest interface{}, query string, args ...interface{}) error

type QueryStat

type QueryStat struct {
	ClusterTable string
	Count        int64
}

type Router

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

func NewRouter

func NewRouter(jscfg []byte) (*Router, error)

func (*Router) MongoExecEventual

func (m *Router) MongoExecEventual(cluster, table string, query func(*mgo.Collection) error) error

func (*Router) MongoExecMonotonic

func (m *Router) MongoExecMonotonic(cluster, table string, query func(*mgo.Collection) error) error

func (*Router) MongoExecStrong

func (m *Router) MongoExecStrong(cluster, table string, query func(*mgo.Collection) error) error

func (*Router) RouterInfo

func (m *Router) RouterInfo(cluster, table string) string

func (*Router) SqlExec

func (m *Router) SqlExec(cluster string, query func(*DB, []interface{}) error, tables ...string) error

func (*Router) SqlExecDeprecated

func (m *Router) SqlExecDeprecated(cluster, table string, query func(*sqlx.DB) error) error

func (*Router) StatInfo

func (m *Router) StatInfo() []*QueryStat

func (*Router) String

func (m *Router) String() string

Jump to

Keyboard shortcuts

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