sql

package
v0.0.0-...-32386f8 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDuplicateEntryError

func IsDuplicateEntryError(err errs.Err) bool

func IsDuplicateExecError

func IsDuplicateExecError(err errs.Err) bool

func SelectAll

func SelectAll(structVal interface{}) string

func SetOpener

func SetOpener(opener Opener)

func WithBeginEndHandler

func WithBeginEndHandler(handler func() (func(), error)) func(*ShardSet)

func WithLogger

func WithLogger(logger *log.Logger) func(*ShardSet)

func WithMetricsHandler

func WithMetricsHandler(handler func(query string, shardName string) func()) func(*ShardSet)

func WithTLS

func WithTLS(tls string) func(*ShardSet)

Types

type ConnVariables

type ConnVariables map[string]string

func (ConnVariables) Join

func (connVars ConnVariables) Join(sep string) string

type Opener

type Opener func(username, password, dbName, host string, port int, connVars ConnVariables) (*sql.DB, errs.Err)

type Shard

type Shard struct {
	DBName string

	BeginEndHandler func() (func(), error)
	MetricsHandler  func(query string, shardName string) func()
	// contains filtered or unexported fields
}

func (*Shard) Exec

func (s *Shard) Exec(query string, args ...interface{}) (sql.Result, errs.Err)

Execute with fixed args

func (*Shard) ExecIgnoreDuplicateError

func (s *Shard) ExecIgnoreDuplicateError(query string, args ...interface{}) (res sql.Result, err errs.Err)

func (*Shard) Insert

func (s *Shard) Insert(query string, args ...interface{}) (id int64, err errs.Err)

func (*Shard) InsertIgnoreDuplicates

func (s *Shard) InsertIgnoreDuplicates(query string, args ...interface{}) (err errs.Err)

func (*Shard) InsertIgnoreId

func (s *Shard) InsertIgnoreId(query string, args ...interface{}) (err errs.Err)

func (*Shard) Query

func (s *Shard) Query(query string, args ...interface{}) (*sql.Rows, errs.Err)

Query with fixed args

func (*Shard) Select

func (s *Shard) Select(output interface{}, query string, args ...interface{}) errs.Err

func (*Shard) SelectInt

func (s *Shard) SelectInt(query string, args ...interface{}) (num int64, err errs.Err)

func (*Shard) SelectIntForce

func (s *Shard) SelectIntForce(query string, args ...interface{}) (num int64, err errs.Err)

func (*Shard) SelectIntMaybe

func (s *Shard) SelectIntMaybe(query string, args ...interface{}) (num int64, found bool, err errs.Err)

func (*Shard) SelectMaybe

func (s *Shard) SelectMaybe(output interface{}, query string, args ...interface{}) (found bool, err errs.Err)

func (*Shard) SelectOne

func (s *Shard) SelectOne(output interface{}, query string, args ...interface{}) (err errs.Err)

func (*Shard) SelectString

func (s *Shard) SelectString(query string, args ...interface{}) (str string, err errs.Err)

func (*Shard) SelectStringForce

func (s *Shard) SelectStringForce(query string, args ...interface{}) (str string, err errs.Err)

func (*Shard) SelectStringMaybe

func (s *Shard) SelectStringMaybe(query string, args ...interface{}) (str string, found bool, err errs.Err)

func (*Shard) SelectUint

func (s *Shard) SelectUint(query string, args ...interface{}) (num uint, err errs.Err)

func (*Shard) SelectUintForce

func (s *Shard) SelectUintForce(query string, args ...interface{}) (num uint, err errs.Err)

func (*Shard) SelectUintMaybe

func (s *Shard) SelectUintMaybe(query string, args ...interface{}) (num uint, found bool, err errs.Err)

func (*Shard) Transact

func (s *Shard) Transact(txFun TxFunc) errs.Err

func (*Shard) TransactWithPropagatedErrors

func (s *Shard) TransactWithPropagatedErrors(txFun TxFunc) errs.Err

func (*Shard) Update

func (s *Shard) Update(query string, args ...interface{}) (rowsAffected int64, err errs.Err)

func (*Shard) UpdateNum

func (s *Shard) UpdateNum(num int64, query string, args ...interface{}) (err errs.Err)

func (*Shard) UpdateOne

func (s *Shard) UpdateOne(query string, args ...interface{}) (err errs.Err)

type ShardSet

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

func NewShardSet

func NewShardSet(username string, password string, host string, port int, dbNamePrefix string, numShards int, maxShards int, maxConns int, options ...func(*ShardSet)) *ShardSet

func (*ShardSet) All

func (s *ShardSet) All() []*Shard

func (*ShardSet) Connect

func (s *ShardSet) Connect() (err errs.Err)

func (*ShardSet) RandomShard

func (s *ShardSet) RandomShard() *Shard

func (*ShardSet) Shard

func (s *ShardSet) Shard(id int64) *Shard

type TxFunc

type TxFunc func(shard *Shard) errs.Err

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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