sql

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(name string,
	masterName string,
	pingInterval time.Duration,
	pingTimesForChangeStatus int,
	pool *pools.ResourcePool) proto.DB

Types

type DB

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

func (*DB) Active

func (db *DB) Active() int64

Active returns the number of active (i.e. non-nil) connections either in the pool or claimed for use

func (*DB) Available

func (db *DB) Available() int64

Available returns the number of currently unused and available connections.

func (*DB) Begin

func (db *DB) Begin(ctx context.Context) (proto.Tx, proto.Result, error)

func (*DB) Capacity

func (db *DB) Capacity() int64

Capacity returns the capacity.

func (*DB) CheckAlive added in v0.4.0

func (db *DB) CheckAlive() error

func (*DB) Close

func (db *DB) Close()

func (*DB) ExecuteFieldList

func (db *DB) ExecuteFieldList(ctx context.Context, table, wildcard string) ([]proto.Field, error)

func (*DB) ExecuteSql

func (db *DB) ExecuteSql(ctx context.Context, sql string, args ...interface{}) (proto.Result, uint16, error)

func (*DB) ExecuteSqlDirectly added in v0.4.0

func (db *DB) ExecuteSqlDirectly(sql string, args ...interface{}) (proto.Result, uint16, error)

func (*DB) ExecuteStmt

func (db *DB) ExecuteStmt(ctx context.Context, stmt *proto.Stmt) (proto.Result, uint16, error)

func (*DB) Exhausted

func (db *DB) Exhausted() int64

Exhausted returns the number of times Available dropped below 1

func (*DB) IdleClosed

func (db *DB) IdleClosed() int64

IdleClosed returns the count of connections closed due to idle timeout.

func (*DB) IdleTimeout

func (db *DB) IdleTimeout() time.Duration

IdleTimeout returns the idle timeout.

func (*DB) InUse

func (db *DB) InUse() int64

InUse returns the number of claimed connections from the pool

func (*DB) IsClosed

func (db *DB) IsClosed() bool

IsClosed returns true if the db is closed.

func (*DB) IsMaster added in v0.4.0

func (db *DB) IsMaster() bool

func (*DB) MasterName added in v0.4.0

func (db *DB) MasterName() string

func (*DB) MaxCap

func (db *DB) MaxCap() int64

MaxCap returns the max capacity.

func (*DB) Name

func (db *DB) Name() string

func (*DB) Ping

func (db *DB) Ping() error

func (*DB) Query

func (db *DB) Query(ctx context.Context, query string) (proto.Result, uint16, error)

func (*DB) QueryDirectly added in v0.4.0

func (db *DB) QueryDirectly(query string) (proto.Result, uint16, error)

func (*DB) ReadWeight added in v0.4.0

func (db *DB) ReadWeight() int

func (*DB) SetCapacity

func (db *DB) SetCapacity(capacity int) error

func (*DB) SetConnectionPostFilters

func (db *DB) SetConnectionPostFilters(filters []proto.DBConnectionPostFilter)

func (*DB) SetConnectionPreFilters

func (db *DB) SetConnectionPreFilters(filters []proto.DBConnectionPreFilter)

func (*DB) SetIdleTimeout

func (db *DB) SetIdleTimeout(idleTimeout time.Duration)

func (*DB) SetReadWeight added in v0.4.0

func (db *DB) SetReadWeight(weight int)

func (*DB) SetWriteWeight added in v0.4.0

func (db *DB) SetWriteWeight(weight int)

func (*DB) StatsJSON

func (db *DB) StatsJSON() string

StatsJSON returns the stats in JSON format.

func (*DB) Status

func (db *DB) Status() proto.DBStatus

func (*DB) UseDB

func (db *DB) UseDB(ctx context.Context, schema string) error

func (*DB) WaitCount

func (db *DB) WaitCount() int64

WaitCount returns the total number of waits.

func (*DB) WaitTime

func (db *DB) WaitTime() time.Duration

WaitTime returns the total wait time.

func (*DB) WriteWeight added in v0.4.0

func (db *DB) WriteWeight() int

type Tx

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

func (*Tx) Close

func (tx *Tx) Close()

func (*Tx) Commit

func (tx *Tx) Commit(ctx context.Context) (result proto.Result, err error)

func (*Tx) ExecuteSql

func (tx *Tx) ExecuteSql(ctx context.Context, sql string, args ...interface{}) (proto.Result, uint16, error)

func (*Tx) ExecuteSqlDirectly added in v0.4.0

func (tx *Tx) ExecuteSqlDirectly(sql string, args ...interface{}) (proto.Result, uint16, error)

func (*Tx) ExecuteStmt

func (tx *Tx) ExecuteStmt(ctx context.Context, stmt *proto.Stmt) (proto.Result, uint16, error)

func (*Tx) Query

func (tx *Tx) Query(ctx context.Context, query string) (proto.Result, uint16, error)

func (*Tx) QueryDirectly added in v0.4.0

func (tx *Tx) QueryDirectly(query string) (proto.Result, uint16, error)

func (*Tx) Rollback

func (tx *Tx) Rollback(ctx context.Context, stmt *ast.RollbackStmt) (result proto.Result, err error)

Jump to

Keyboard shortcuts

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