backend

package
v0.0.0-...-0d6b514 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Up = iota
	Down
	ManualDown
	Unknown

	PingPeroid int64 = 4
)
View Source
const (
	DefaultCapacity    = 128
	DefaultMaxCapacity = 1024
)

Variables

View Source
var (
	DefaultOption = &Option{
		idleTimeout: defaultIdleTimeout,
		connTimeout: defaultConnTimeout,
		maxCapacity: DefaultMaxCapacity,
		capacity:    DefaultCapacity,
		charset:     mysql.DEFAULT_CHARSET,
		collationId: mysql.DEFAULT_COLLATION_ID,
	}
)
View Source
var (
	// ErrConnectionPoolClosed means pool closed error
	ErrConnectionPoolClosed = errors.New("connection pool is closed")
)

Functions

func Gcd

func Gcd(ary []int) int

Types

type Conn

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

proxy <-> mysql server

func (*Conn) Begin

func (c *Conn) Begin() error

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) ClosePrepare

func (c *Conn) ClosePrepare(id uint32) error

func (*Conn) Commit

func (c *Conn) Commit() error

func (*Conn) Connect

func (c *Conn) Connect(addr string, user string, password string, db string) error

func (*Conn) Execute

func (c *Conn) Execute(command string, args ...interface{}) (*mysql.Result, error)

func (*Conn) FieldList

func (c *Conn) FieldList(table string, wildcard string) ([]*mysql.Field, error)

func (*Conn) GetAddr

func (c *Conn) GetAddr() string

func (*Conn) GetCharset

func (c *Conn) GetCharset() string

func (*Conn) GetDB

func (c *Conn) GetDB() string

func (*Conn) IsAutoCommit

func (c *Conn) IsAutoCommit() bool

func (*Conn) IsInTransaction

func (c *Conn) IsInTransaction() bool

func (*Conn) Ping

func (c *Conn) Ping() error

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (*Stmt, error)

func (*Conn) ReConnect

func (c *Conn) ReConnect() error

func (*Conn) Rollback

func (c *Conn) Rollback() error

func (*Conn) SetAutoCommit

func (c *Conn) SetAutoCommit(n uint8) error

func (*Conn) SetCharset

func (c *Conn) SetCharset(charset string, collation mysql.CollationId) error

func (*Conn) UseDB

func (c *Conn) UseDB(dbName string) error

type DB

type DB struct {
	sync.RWMutex

	*resource_polll.ResourcePool
	// contains filtered or unexported fields
}

func Open

func Open(addr string, user string, password string, dbName string, opts ...DbOption) (*DB, error)

func (*DB) Addr

func (db *DB) Addr() string

func (*DB) Close

func (db *DB) Close()

func (*DB) Execute

func (db *DB) Execute(command string, args ...interface{}) (*mysql.Result, error)

func (*DB) GetConn

func (db *DB) GetConn() (*Conn, error)

func (*DB) Ping

func (db *DB) Ping() error

func (*DB) PutConn

func (db *DB) PutConn(c *Conn)

func (*DB) State

func (db *DB) State() string

type DbOption

type DbOption func(o *Option)

func WithCapacity

func WithCapacity(capacity int) DbOption

func WithCharSet

func WithCharSet(charset string) DbOption

func WithCollationId

func WithCollationId(ci mysql.CollationId) DbOption

func WithConnTimeout

func WithConnTimeout(connTimeout time.Duration) DbOption

func WithIdleTimeout

func WithIdleTimeout(idleTimeout time.Duration) DbOption

func WithMaxCapacity

func WithMaxCapacity(maxCapacity int) DbOption

type Option

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

type Stmt

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

func (*Stmt) Close

func (s *Stmt) Close() error

func (*Stmt) ColumnNum

func (s *Stmt) ColumnNum() int

func (*Stmt) Execute

func (s *Stmt) Execute(args ...interface{}) (*mysql.Result, error)

func (*Stmt) GetId

func (s *Stmt) GetId() uint32

func (*Stmt) ParamNum

func (s *Stmt) ParamNum() int

Jump to

Keyboard shortcuts

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