import "gopkg.in/src-d/go-vitess.v1/vt/vttablet/tabletserver/connpool"
var ErrConnPoolClosed = vterrors.New(vtrpcpb.Code_INTERNAL, "internal error: unexpected: conn pool is closed")
ErrConnPoolClosed is returned when the connection pool is closed.
BinlogFormat is used for specifying the binlog format.
const ( BinlogFormatStatement BinlogFormat = iota BinlogFormatRow BinlogFormatMixed )
The following constants specify the possible binlog format values.
type DBConn struct {
// contains filtered or unexported fields
}
DBConn is a db connection for tabletserver. It performs automatic reconnects as needed. Its Execute function has a timeout that can kill its own queries and the underlying connection. It will also trigger a CheckMySQL whenever applicable.
NewDBConn creates a new DBConn. It triggers a CheckMySQL if creation fails.
func NewDBConnNoPool(params *mysql.ConnParams, dbaPool *dbconnpool.ConnectionPool) (*DBConn, error)
NewDBConnNoPool creates a new DBConn without a pool.
Close closes the DBConn.
Current returns the currently executing query.
func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
Exec executes the specified query. If there is a connection error, it will reconnect and retry. A failed reconnect will trigger a CheckMySQL.
func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
ExecOnce executes the specified query, but does not retry on connection errors.
ID returns the connection id.
IsClosed returns true if DBConn is closed.
Kill kills the currently executing query both on MySQL side and on the connection side. If no query is executing, it's a no-op. Kill will also not kill a query more than once.
Recycle returns the DBConn to the pool.
func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, streamBufferSize int, includedFields querypb.ExecuteOptions_IncludedFields) error
Stream executes the query and streams the results.
func (dbc *DBConn) VerifyMode(strictTransTables bool) (BinlogFormat, error)
VerifyMode is a helper method to verify mysql is running with sql_mode = STRICT_TRANS_TABLES or STRICT_ALL_TABLES and autocommit=ON. It also returns the current binlog format.
type MySQLChecker interface {
CheckMySQL()
}
MySQLChecker defines the CheckMySQL interface that lower level objects can use to call back into TabletServer.
type Pool struct {
// contains filtered or unexported fields
}
Pool implements a custom connection pool for tabletserver. It's similar to dbconnpool.ConnPool, but the connections it creates come with built-in ability to kill in-flight queries. These connections also trigger a CheckMySQL call if we fail to connect to MySQL. Other than the connection type, ConnPool maintains an additional pool of dba connections that are used to kill connections.
New creates a new Pool. The name is used to publish stats only.
Active returns the number of active connections in the pool
Available returns the number of available connections in the pool
Capacity returns the pool capacity.
Close will close the pool and wait for connections to be returned before exiting.
Get returns a connection. You must call Recycle on DBConn once done.
IdleClosed returns the number of closed connections for the pool.
IdleTimeout returns the idle timeout for the pool.
InUse returns the number of in-use connections in the pool
MaxCap returns the maximum size of the pool
func (cp *Pool) Open(appParams, dbaParams, appDebugParams *mysql.ConnParams)
Open must be called before starting to use the pool.
Put puts a connection into the pool.
SetCapacity alters the size of the pool at runtime.
SetIdleTimeout sets the idleTimeout on the pool.
StatsJSON returns the pool stats as a JSON object.
WaitCount returns how many clients are waiting for a connection
WaitTime return the pool WaitTime.
Package connpool imports 18 packages (graph) and is imported by 5 packages. Updated 2019-06-13. Refresh now. Tools for package owners.